# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
377217 |
2021-03-13T11:48:56 Z |
OptxPrime |
Trol (COCI19_trol) |
C++11 |
|
1 ms |
364 KB |
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
int f( long long x )
{
if( x%9 != 0 ) return x%9;
else return 9;
}
int main()
{
long long q,l,r, suma;
cin>>q;
for(int i=0;i<q;i++){
cin>>l>>r;
suma = 0;
//cout << nadjiSumu(l,r)<<endl;
long long brojBlokova = (r-l+1)/9;
suma = brojBlokova*45;
long long visak = (r-l+1)%9;
if( visak!=0 ){
long long zadnji = f(r);
long long prvi = f(l);
while( zadnji != prvi ){
suma += zadnji;
zadnji--;
if( zadnji == 0 ) zadnji = 9;
}
suma += zadnji;
}
cout<<suma<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |