# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
335226 | 2020-12-11T15:44:59 Z | CaroLinda | Trol (COCI19_trol) | C++14 | 1 ms | 364 KB |
#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
# | 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 |