Submission #975527

# Submission time Handle Problem Language Result Execution time Memory
975527 2024-05-05T12:18:26 Z vjudge1 Trol (COCI19_trol) C++17
0 / 50
1 ms 504 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=x*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/9)*9;
		x45=x*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 Incorrect 1 ms 504 KB Output isn't correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Incorrect 0 ms 348 KB Output isn't correct