# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
231136 | jungsnow | Trol (COCI19_trol) | C++14 | 5 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |