# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
238740 | Halit | Trol (COCI19_trol) | C++17 | 6 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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, lans;
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;
}
templ = (10 - ((reml == 0) * 9 + reml)) + l;
tempr = r - ((remr == 0) * 9 + remr - 1);
lans = 45 - (9 - (10 - ((reml == 0) * 9 + reml))) * (10 - (10 - ((reml == 0) * 9 + reml))) / 2;
nons = (tempr - templ + 1) / 9 * 45;
rans = (remr * remr + remr) / 2 - 1;
if(cannot){
NEXT : ;
tempr = r - ((remr == 0) * 9 + remr - 1);
nons = (tempr) / 9 - 1;
rans = (remr * remr + remr) / 2 - 1;
}
ans = nons + rans + lans + 1;
cout << ans << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |