Submission #377217

#TimeUsernameProblemLanguageResultExecution timeMemory
377217OptxPrimeTrol (COCI19_trol)C++11
50 / 50
1 ms364 KiB
#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 timeMemoryGrader output
Fetching results...