D. Happy New Year!
Title link: https://ac.nowcoder.com/acm/contest/9983/D
Title description:
New Year's Eve in one week! Niuniu stared at the new desk calendar that day. He suddenly wanted to know the smallest year that is greater than \mathit nn and the same as \mathit nn for the year \mathit nn.
The sum of the digits of a number is equal to the sum of the digits of its digits. For example, the sum of the digits of 2021 is equal to 2+0+2+1=5.
Enter a description:
A positive integer n.
2021≤n≤2030
Output description:
Output a positive integer to represent the answer.
Example 1:
Enter
2025 and
output
2034,
indicating that
2034 is the smallest positive integer greater than 2025 and the sum of digits is equal to 9.
Problem-solving ideas:
Sign-in questions.
When 2021≤n≤2029, output n+10-1. In special cases, when n=2030, output 2102.
code show as below:
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
if(n<=2029)
printf("%d\n",n+9);
if(n==2030)
printf("2102\n");
return 0;
}