Submission #937192

#TimeUsernameProblemLanguageResultExecution timeMemory
937192Omar_GTrol (COCI19_trol)C++17
50 / 50
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define Omar_G ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define ll /*Omar-G*/ long long #define endl/*Omar-G*/ "\n" #define ss /*Omar-G*/ string const ll mod = 1e9 + 7; void solve() { ll q; cin >> q; while (q--) { ll l, r; cin >> l >> r; l--; ll a = r - l; ll ans = (a / 9) * 45; l = (l % 9) ? l % 9 : 9; r = (r % 9) ? r % 9 : 9; if (r >= l) { ans += (r * (r + 1) / 2) - (l * (l + 1) / 2); } else { ans += (r * (r + 1) / 2) + 45 - (l * (l + 1) / 2); } cout << ans << endl; } } void solveT() {ll t; cin >> t; while (t--) solve();} int main() { Omar_G solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...