Submission #308468

#TimeUsernameProblemLanguageResultExecution timeMemory
308468ncduy0303Trol (COCI19_trol)C++14
50 / 50
1 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define ar array #define ll long long const int MAX_N = 1e5 + 1; const int MOD = 1e9 + 7; const int INF = 1e9; const ll LINF = 1e18; void solve() { ll l, r; cin >> l >> r; ll ans = (r - l + 1) / 9 * 45; for (int i = 0; i < (r - l + 1) % 9; i++) { int tmp = (l + i) % 9; if (tmp == 0) tmp = 9; ans += tmp; } cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int tc; cin >> tc; for (int t = 1; t <= tc; t++) { // cout << "Case #" << t << ": "; solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...