답안 #689646

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
689646 2023-01-29T04:17:09 Z Warinchai Trol (COCI19_trol) C++14
50 / 50
1 ms 212 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
	int q;
	cin>>q;
	long long sum=0;
	long long a,b;
	long long dif;
	long long ii=0;
	long long ddd;
	for(int i=0;i<q;i++){
		cin>>a>>b;
		sum=0;
		int da=a%9;
		int db=b%9;
		dif=b-a+1;
		ddd=dif/9;
		sum+=ddd*45;
		for(ii=a+ddd*9;ii<=b;ii++){
			int x=ii%9;
			if(x==0){
				x=9;
			}
			sum+=x;
		}
		cout<<sum<<endl;
	}
}

Compilation message

trol.cpp: In function 'int main()':
trol.cpp:14:7: warning: unused variable 'da' [-Wunused-variable]
   14 |   int da=a%9;
      |       ^~
trol.cpp:15:7: warning: unused variable 'db' [-Wunused-variable]
   15 |   int db=b%9;
      |       ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct