题目连接:

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;
}

相关文章:

  • 2021-12-07
  • 2022-03-05
  • 2022-02-19
  • 2021-10-27
  • 2021-08-26
  • 2021-08-23
  • 2021-11-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-27
  • 2022-02-25
  • 2021-08-02
  • 2021-06-27
  • 2021-11-19
  • 2021-05-16
相关资源
相似解决方案