Submission #231136

#TimeUsernameProblemLanguageResultExecution timeMemory
231136jungsnowTrol (COCI19_trol)C++14
50 / 50
5 ms384 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; ll L, R; void solve() { cin >> L >> R; ll mi[9]; for (int i = 0; i < 9; i++) mi[i] = 2e18; for (int i = 0; i < 10; i++) { ll nVal = (L + i); if (nVal > R) break; mi[nVal % 9] = min(mi[nVal % 9], nVal); } ll sum = 0; for (int i = 0; i < 9; i++) { if (mi[i] == 2e18) continue; //cerr<<i<<' '<<mi[i]<<'\n'; ll cnt = (R - mi[i]) / 9 + 1; if (i == 0) sum += 9 * cnt; else sum += i * cnt; } cout << sum << '\n'; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T; cin >> T; while (T--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...