cf 808 A

来源:互联网 发布:表白源码 编辑:程序博客网 时间:2024/05/22 00:21

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.

Example
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.


水题,发这个题的目的只有一个,因为比赛的时候居然wa了一下,错误让我 也很尴尬

先看代码

#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>using namespace std;int main(){    int n;    while(cin>>n)    {        int x;        int k=0;        int m=n;        while(n)        {            k++;            x=n%10;            n=n/10;        }        int sum=(x+1);        for(int i=1;i<k;i++)            sum*=10;        cout<<sum-m<<endl;    }    return 0;}

第一发用了pow(10,k-1),错了,后来只好改为for循环了。。。。

原创粉丝点击