A - Find Multiple Editorial by en_translator

If you are new to learning programming and do not know where to start, please try Problem A “Welcome to AtCoder” from practice contest. There you can find a sample code for each language.

Let \(X\) be the quotient of \(B\) divided by \(C\), with the remainder rounded down, that is, \(X=\lfloor \frac{B}{C} \rfloor\).

Let \(Y=X \times C\).
Then \(Y\) is the minimum multiple of \(C\) not exceeding \(B\).

Therefore, if \(Y \geq A\), then \(Y\) is an answer.
If \(Y \lt A\), then the answer is \(-1\).

A sample code in C++ follows.

using namespace std;
typedef long long ll;

signed main(){
    ll a,b,c;
    ll Y = b / c * c; // Y is a multiplt of C not exceeding B
    if(a <= Y){
    return 0;

last update: