# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
249372 | tushar_2658 | Trol (COCI19_trol) | C++14 | 1 ms | 256 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"
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |