Educational Codeforces Round 13 A. Johny Likes Numbers 水题

A. Johny Likes Numbers

题目连接:

http://www.codeforces.com/contest/678/problem/A

Description

Johny likes numbers n and k very much. Now Johny wants to find the smallest integer x greater than n, so it is divisible by the number k.

Input

The only line contains two integers n and k (1 ≤ n, k ≤ 109).

Output

Print the smallest integer x > n, so it is divisible by the number k.

Sample Input

5 3

Sample Output

6

Hint

题意

找到一个大于n的最小值p,使得p%k==0

题解:

O1公式题

答案是(n/k+1)k

显然。

代码

#include<bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int main()
{
    long long n,k;
    cin>>n>>k;
    cout<<(n/k+1)*k<<endl;
    return 0;
}
原文地址:https://www.cnblogs.com/qscqesze/p/5582663.html