# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
377217 | OptxPrime | Trol (COCI19_trol) | C++11 | 1 ms | 364 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |