# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
249372 | 2020-07-14T17:53:18 Z | tushar_2658 | Trol (COCI19_trol) | C++14 | 1 ms | 256 KB |
#include "bits/stdc++.h" using namespace std; const int maxn = 105; using ll = long long; int get(ll x){ while(x > 9){ int sum = 0; while(x > 9){ sum += x % 10; x /= 10; } sum += x; x = sum; } return x; } ll f(ll x){ ll ret = 45 * (x / 9); x %= 9; ret += (x * (x + 1))/2; return ret; } int main(int argc, char const *argv[]) { int q; scanf("%d", &q); while(q--){ ll l, r; scanf("%lld %lld", &l, &r); printf("%lld\n", f(r) - f(l - 1)); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |