답안 #975531

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975531 2024-05-05T12:24:55 Z vjudge1 Trol (COCI19_trol) C++17
0 / 50
1 ms 856 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/9)*9;
		x45=(l/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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Incorrect 1 ms 856 KB Output isn't correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Incorrect 0 ms 348 KB Output isn't correct