# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
320584 | man_in_danger | Trol (COCI19_trol) | C++11 | 1 ms | 384 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.
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define speedup ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef pair<int, int> PII;
ll mod = 1e9+7;
ll inf = 1e18;
int dig(ll n){
ll ret = 0;
while(n){
ret += n % 10;
n /= 10;
}
return ret;
}
int main()
{
speedup;
int t;
cin >> t;
while(t--){
ll l, r, dif, i = 0, ans = 0;
cin >> l >> r;
dif = r - l;
ll st = l;
while(st > 9){
st = dig(st);
}
while(i < 9 && dif >= 0){
if(st > 9) st = 1;
ans += st + ((dif / 9) * st);
st++;
dif--;
i++;
}
cout << ans << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |