# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
975532 |
2024-05-05T12:31:10 Z |
vjudge1 |
Trol (COCI19_trol) |
C++17 |
|
1 ms |
500 KB |
#include <bits/stdc++.h>
using namespace std;
int main(){
int q;cin>>q;
int ans[q];
for(int k=0;k<q;k++){
int l,r;cin>>l>>r;
int kanan,kiri;
int x=(r/9)*9;
int x45=(r/9)*45;
int cnt1=0;
for(int i=x+1;i<=r;i++){
if(i%9!=0){
cnt1+=i%9;
}else{
cnt1+=9;
}
}
kanan=x45+cnt1;
int cnt2=0;
x=((l-1)/9)*9;
x45=((l-1)/9)*45;
for(int i=x+1;i<=l-1;i++){
if(i%9!=0){
cnt2+=i%9;
}else{
cnt2+=9;
}
}
kiri=x45+cnt2;
ans[k]=kanan-kiri;
}
for(int i=0;i<q;i++){
cout<<ans[i]<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Correct |
1 ms |
500 KB |
Output is correct |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |