# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
976435 | vjudge1 | Trol (COCI19_trol) | C++17 | 1 ms | 348 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;
typedef long long ll;
int main()
{
int q;
cin >> q;
while (q--) {
ll l, r;
cin >> l >> r;
int ans = 0;
ll selisih = (r-l)/9;
int sisa = (r-l)%9;
int hah = l%9;
for (int i=hah;i<=8+hah;i++) {
if (i == 0) {
ans += 9*selisih;
}
else {
ans += i*selisih;
}
}
for (int i=hah;i<=(hah)+sisa;i++) {
if (i == 0) {
ans += 9;
}
else {
ans += i;
}
}
cout << ans << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |