# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
335226 | CaroLinda | Trol (COCI19_trol) | C++14 | 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 <bits/stdc++.h>
#define ll long long
using namespace std ;
int Q ;
ll L , R ;
int main()
{
scanf("%d", &Q ) ;
ll val[9] = {9,1,2,3,4,5,6,7,8} ;
ll cte = 45 ;
while(Q--)
{
scanf("%lld %lld", &L , &R ) ;
ll ans = 0LL ;
if(R - L + 1 <= 1000 )
{
for(ll i = L ; i <= R ; i++ ) ans += val[ i%9 ] ;
printf("%lld\n", ans ) ;
continue ;
}
for(; L % 9 != 0 ; L++ ) ans += val[L%9] ;
for(; R % 9 != 8 ; R--) ans += val[ R%9 ] ;
ans += cte * ( (R-L+1)/9LL ) ;
printf("%lld\n", ans ) ;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |