# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
725408 | TheSahib | Trol (COCI19_trol) | C++17 | 1 ms | 304 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>
#pragma GCC optimize("O3")
#define ll long long
#define pii pair<ll, ll>
using namespace std;
ll f(ll a){
ll ans = 0;
while(a){
ans += a % 10;
a /= 10;
}
return ans;
}
int main(){
int q; cin >> q;
while(q--){
ll l, r; cin >> l >> r;
ll l1 = l;
while(l1 != f(l1)){
l1 = f(l1);
}
ll r1 = r;
while(r1 != f(r1)){
r1 = f(r1);
}
ll ans = 0;
while(l1 != 1 && l <= r){
ans += l1;
l1++;
if(l1 == 10) l1 = 1;
l++;
}
while(r1 != 9 && l <= r){
ans += r1;
r1--;
if(r1 == 0) r1 = 9;
r--;
}
ans += (r - l + 3) / 10 * 10 * 9 / 2;
cout << ans << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |