# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
238742 |
2020-06-12T14:12:47 Z |
Halit |
Trol (COCI19_trol) |
C++17 |
|
5 ms |
384 KB |
#include <bits/stdc++.h>
using namespace std;
const bool cannot = 0;
int main(){
int q;
cin >> q;
while(q--){
long long l,r, templ, tempr, reml, remr, nons, ans = 0, rans = 0, lans = 0;
cin >> l >> r;
reml = l % 9;
remr = r % 9;
if(l <= 9 && r <= 9){
for(int i = l;i <= r;i++)
ans += i;
cout << ans << "\n";
continue;
}
else if(l <= 9){
lans = 45 - (l) * (l-1) / 2;
goto NEXT;
}
if(reml != 1)
templ = (10 - ((reml == 0) * 9 + reml)) + l;
else
templ = l;
if(remr != 1)
tempr = r - ((remr == 0) * 9 + remr - 1);
else
tempr = r;
if(reml != 1)
lans = 45 - (9 - (10 - ((reml == 0) * 9 + reml))) * (10 - (10 - ((reml == 0) * 9 + reml))) / 2;
nons = (tempr - templ + 1) / 9 * 45;
if(remr != 1)
rans = (remr * remr + remr) / 2 - 1;
if(cannot){
NEXT : ;
tempr = r - ((remr == 0) * 9 + remr - 1);
nons = (tempr) / 9 - 1;
if(remr != 1)
rans = (remr * remr + remr) / 2 - 1;
}
ans = nons + rans + lans + 1;
cout << ans << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
5 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |