Codeforces 1183A Nearest Interesting Number

题目链接:http://codeforces.com/problemset/problem/1183/A


题意:求不小于 a 且每位数和能被 4 整除的 最小 n

思路:暴力模拟就好。

AC代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int a;
 6     cin >> a;
 7     bool flag = true;
 8     int ans = 0;
 9     while(flag)
10     {
11         int t = a;
12         ans = 0;
13         while(t)
14         {
15             ans += t%10;
16             t/=10;
17         }
18         if(ans % 4 == 0) flag = false;
19         else a++;
20     }
21     cout << a ;
22     return 0;
23 }

猜你喜欢

转载自www.cnblogs.com/Carered/p/11099716.html
今日推荐