Submission #976747

# Submission time Handle Problem Language Result Execution time Memory
976747 2024-05-07T05:07:46 Z vjudge1 Trol (COCI19_trol) C++17
30 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
int jumlah(int x){
	int ans=45*(x/9);
	if(x%9!=0){
		for(int i=x%9; i>0; i--){
			ans+=i;
		}
	}
	return ans;
}
int main(){
	int Q,maks=0;
	cin>>Q;
	unsigned long long L[Q],R[Q];
	for(int i=0; i<Q; i++){
		int ans=0;
		cin>>L[i]>>R[i];
		cout<<jumlah(R[i])-jumlah(L[i]-1)<<endl;
		
	}
}

Compilation message

trol.cpp: In function 'int main()':
trol.cpp:17:7: warning: unused variable 'ans' [-Wunused-variable]
   17 |   int ans=0;
      |       ^~~
trol.cpp:13:8: warning: unused variable 'maks' [-Wunused-variable]
   13 |  int Q,maks=0;
      |        ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 0 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct