# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1256873 | ipeksoysal | Trol (COCI19_trol) | C++20 | 0 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
main()
{
int n, a, b, top;
cin >> n;
for(int i=0; i<n; i++){
top=0;
cin>> a >> b;
if(b-a+1>9){
int cark = b - a + 1;
cark -= 9 - a%9 + 1;
cark -= b%9;
cark = cark / 9;
top += cark * 45;
int A = a;
int B = b;
for(int y=1; y<= 9 - A%9 + 1; y++){
if(a%9==0)
top+=9;
else
top+=a%9;
a++;
}
for(int y=1; y<= B%9; y++){
if(b%9==0)
top+= 9;
else
top+=b%9;
b--;
}
}
else{
for(int y=a; y<=b; y++){
top+=y%9;
if(y%9==0)
top+=9;
}
}
cout << top << "\n";
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |