답안 #976702

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976702 2024-05-07T03:19:14 Z vjudge1 Trol (COCI19_trol) C++11
20 / 50
1000 ms 408 KB
#include <bits/stdc++.h>
using namespace std;

int f(int x){
	while (x > 9) {
		int cur = x;
		int sum = 0;
		while (cur != 0){
			sum += cur % 10;
			cur /= 10;
		}
		x = sum;
	}
	return x;
}

int calc(int l, int r) {
	int ret = 0;
	for (int i = l; i <= r; i++){
		ret += f(i);
	}
	return ret;
}

int main() {
	int Q;
	cin >> Q;
	while (Q--){
		int l, r;
		cin >> l >> r;
		cout << calc(l,r) << endl;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Execution timed out 1089 ms 408 KB Time limit exceeded
5 Incorrect 0 ms 344 KB Output isn't correct