Submission #814587

#TimeUsernameProblemLanguageResultExecution timeMemory
814587tlnk07Trol (COCI19_trol)C++17
50 / 50
1 ms316 KiB
#include <bits/stdc++.h> using namespace std; long long q, l, r, ans; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> q; while(q--) { ans = 0; cin >> l >> r; if((r - l + 1) % 9 == 0) { ans = (r - l + 1) * 5; cout << ans << "\n"; } else { ans = (r - l + 1) / 9 * 45; long long t = (r - l + 1) % 9; while(t--) { if(l % 9 == 0) { ans += 9; } else { ans += l % 9; } ++l; } cout << ans << "\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...