# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
892078 |
2023-12-24T18:36:29 Z |
kh0i |
Trol (COCI19_trol) |
C++17 |
|
1 ms |
348 KB |
/**
* author: kh0i
* created: 21.03.2022 11:35:07
**/
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif
using ll = long long;
ll sol(ll x){
ll res = 0;
ll k = x / 9;
res += k * 45;
x = x % 9;
for(int i = 1; i <= x; ++i)
res += i;
return res;
}
void solve(){
ll l, r;
cin >> l >> r;
cout << sol(r) - sol(l - 1) << '\n';
}
int32_t main() {
cin.tie(nullptr)->sync_with_stdio(0);
int test = 1;
cin >> test;
for(int i = 1; i <= test; ++i){
solve();
}
cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
return 0;
}
// Write stuff down
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |