A. Nearest Interesting Number #570 DIV3 A (水题)

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;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值