# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1257856 | arnaa | Trol (COCI19_trol) | C++20 | 1 ms | 328 KiB |
#include<bits/stdc++.h>
using namespace std;
int digit(long long x){
if(x<=0) return 0;
long long jum = x / 9;
long long ans = x % 9;
return jum * 45 + ( ans * ( ans + 1 )) /2;
}
int main(){
int q;
long long l,r;
cin>>q;
for(int i=1;i<=q;i++){
cin>>l>>r;
long long ans= digit(r) - digit(l-1);
cout<<ans<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |