Submission #320584

#TimeUsernameProblemLanguageResultExecution timeMemory
320584man_in_dangerTrol (COCI19_trol)C++11
50 / 50
1 ms384 KiB
//#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 timeMemoryGrader output
Fetching results...