#include <bits/stdc++.h>
using namespace std;
int calc(int num){
int ans = 0;
while(num != 0){
ans += num % 10;
num /= 10;
}
return ans;
}
int main(){
int Q, L, R, ans1, ans2, temp;
cin >> Q;
for(int j =0; j<Q; j++){
cin >> L;
ans1 = calc(L);
while(ans1 > 10){
temp = calc(ans1);
ans1 = temp;
}
cin >> R;
ans2 = calc(R);
while(ans2 > 10){
temp = calc(ans2);
ans2 = temp;
}
if(ans1 != ans2){
cout << ans1 << ans2 << endl;
}else{
cout << ans1 << endl;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
584 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
432 KB |
Output isn't correct |