1 solutions
-
0
C++ :
#include<bits/stdc++.h> using namespace std; long long q,a,b,ans; int f(long long x) { while(x>=10) { int tmp=0; for(long long i=x;i>0;i/=10) tmp+=i%10; x=tmp; } return x; } int main() { cin>>q; while(q--) { cin>>a>>b; long long lun=(b-a+1)/9; long long yu=(b-a+1)%9; ans=45*lun; for(int i=f(a),j=1;j<=yu;i++,j++) { if(i==10) i=1; ans+=i; } cout<<ans<<endl; } return 0; }
- 1
Information
- ID
- 987
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By