Educational Codeforces Round 23 C. Really Big Numbers

来源:互联网 发布:网络冗余技术应用 编辑:程序博客网 时间:2024/06/07 01:24

C. Really Big Numbers
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is not less than s. To prove that these numbers may have different special properties, he wants to know how rare (or not rare) they are — in fact, he needs to calculate the quantity of really big numbers that are not greater than n.

Ivan tried to do the calculations himself, but soon realized that it's too difficult for him. So he asked you to help him in calculations.

Input

The first (and the only) line contains two integers n and s (1 ≤ n, s ≤ 1018).

Output

Print one integer — the quantity of really big numbers that are not greater than n.

Examples
input
12 1
output
3
input
25 20
output
0
input
10 9
output
1
Note

In the first example numbers 1011 and 12 are really big.

In the second example there are no really big numbers that are not greater than 25 (in fact, the first really big number is 3030 - 3 ≥ 20).

In the third example 10 is the only really big number (10 - 1 ≥ 9).

题目意思一开始没看懂  0.0...

然后问过别人后,就是说给定一个s和一个n问,从1开始到s有多少个数减去它的位数和大于等于n。。

然后暴力。。。

#include<bits/stdc++.h>#include<iostream>#define ll long longusing namespace std;int main(){    ll n,s;    cin>>n>>s;    ll ans=0;    for(ll i=s+1;i<=s+200&&i<=n;i++)    {        ll t=i;        ll r=0;        while(t!=0)        {            r+=t%10;            t=t/10;        }        if(r+s<=i)ans++;    }    s=s+200;    long long int m=0;    ans=ans+max(n-s,m);    cout<<ans<<endl;}




原创粉丝点击