interesting
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Polycarp knows that if the sum of the digits of a number is pisible by 33, then the number itself is pisible by 33. He assumes that the numbers, the sum of the digits of which is pisible by 44, are also somewhat interesting. Thus, he considers a positive integer nn interesting if its sum of digits is pisible by 44.
Help Polycarp find the nearest larger or equal interesting number for the given number aa. That is, find the interesting number nn such that n≥an≥a and nn is Minimal.
Input
The only line in the input contains an integer aa (1≤a≤10001≤a≤1000).
Output
print the nearest greater or equal interesting number for the given number aa. In other words, print the interesting number nn such that n≥an≥a and nn is minimal.
input
Copy
432
output
Copy
435
input
Copy
99
output
Copy
103
input
Copy
237
output
Copy
237
input
Copy
42
output
Copy
44
解题说明:水题,求每一位数字之和,然后开始遍历直到能被4整除即可。
#include<cstdio>
#include<iOStream>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
int a, i, s = 0;
scanf("%d", &a);
i = a;
while (1)
{
a = i;
while (a != 0)
{
s = s + a % 10;
a = a / 10;
}
if (s % 4 == 0)
{
break;
}
i++;
s = 0;
}
printf("%d\n", i);
return 0;
}
文章最后发布于: 2019-06-28 20:55:45
相关阅读
在之前,有一个数据需要存在数据库中的格式类似“58-001”这种的,其中58和1都是分别获取的,然后想组合成“58-001”的字符串保存
ROW_NUMBER() OVER(PARTITION BY bid, axisid ORDER BY endtime DESC) AS rownum
magic number:魔数,这是放在linux的目录中的文件信息块中的一个标识符,一般只有几位,用来标识该文件是什么类型的文件,可以
Spring框架中@DateTimeFormat和@NumberFormat的用法
@DateTimeFormat是用来验证输入的日期格式;@NumberFormat是用来验证输入的数字格式。有时候,因为输入习惯或某些要求必须改变格式的
Swagger2 java.lang.NumberFormatException异常解决
Swagger异常1. 问题2. 原因3. 解决1. 问题 访问swagger ui 时,会出现下面异常,虽然不影响使用,但是看着很不舒服。java.lang.NumberF