1、难点在于读题,输入两个数x,k,从x开始递增寻找最小可整除k的数。
- #include
- using namespace std;
- int main()
- {
- int x, k;
- int n;
- cin >> n;
- while (n--)
- {
- cin >> x >> k;
- int sum = 0;
- int a = x;
- for (int i = x;; i++)
- {
- int sum = 0;
- int a = i;
- while (a)
- {
- sum +=a % 10;
- a /= 10;
- }
- if (sum % k==0)
- {
- cout << i << endl;
- break;
- }
- }
- }
- }