您的位置:首页 > 其它

codeforces——808A——Lucky Year

2017-05-29 08:35 253 查看
A. Lucky Year

time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

Apart from having lots of holidays throughout the year, residents of Berland also have wholelucky years. Year is considered
lucky if it has no more than
1 non-zero digit in its number. So years 100, 40000, 5 arelucky and 12, 3001 and 12345 are not.

You are given current year in Berland. Your task is to find how long will residents of Berland wait till the nextlucky year.

Input
The first line contains integer number n (1 ≤ n ≤ 109) — current year in Berland.

Output
Output amount of years from the current year to the next
lucky one.

Examples

Input
4


Output
1


Input
201


Output
99


Input
4000


Output
1000


Note
In the first example next lucky year is 5. In the second one — 300. In the third — 5000.

问大于所给数字的下一个仅有一个非0的数字与所给数字的差

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
long long func1(int n);//原本是使用了pow()函数,但是提交时出现了问题,cf显示第二组数据输出98,但是我的测试是输出了99,很奇怪。自己写了个函数就过了。
int main()
{
int n;
while(cin>>n!=NULL)
{
char s[20];
sprintf(s,"%d",n);
int n2=strlen(s);
cout<<(n/func1(n2-1)+1)*func1(n2-1)-n<<endl;
}
return 0;
}
long long func1(int n)
{
long long ans=1;
while(n--)
ans*=10;
return ans;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: