# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211885 | aloomya | Trol (COCI19_trol) | C++17 | 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;
#define int long long
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
using PII = pair<int, int>;
const int MAX_N = 3e5 + 10, MOD = 1e9 + 7, INF = 3e18, NINF = -3e18;
int p[9] = {0, 1, 3, 6, 10, 15, 21, 28, 36};
int sol(int r){
return (r / 9) * 45 + p[r % 9];
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie();
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int l, r;
cin >> l >> r;
cout << sol(r) - sol(l - 1) << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |