A. Nearest Interesting Number
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Polycarp knows that if the sum of the digits of a number is divisible by 33, then the number itself is divisible by 33. He assumes that the numbers, the sum of the digits of which is divisible by 44, are also somewhat interesting. Thus, he considers a positive integer nn interesting if its sum of digits is divisible 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.
Examples
inputCopy
432
outputCopy
435
inputCopy
99
outputCopy
103
inputCopy
237
outputCopy
237
inputCopy
42
outputCopy
44
#include<stdio.h>
int f(int v)
{
if(!v)
return 0;
return v % 10 + f(v / 10);
}
int n;
int main()
{
scanf("%d",&n);
while(f(n)%4)
n++;
printf("%d\n",n);
return 0;
}