Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int arr[]= {0,1,3,6,10,15,21,28,36,45};
- long long func(long long n)
- {
- long long sum = 0;
- while(n)
- {
- sum += (n/10)*45 + arr[n%10];
- n/=10;
- }
- return sum;
- }
- int main()
- {
- long long n,m,i;
- while(scanf("%lld%lld",&n,&m)==2)
- {
- if(n<0 && m<0)
- break;
- printf("%lld\n",func(m)-func(n-1));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment