# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
975476 | vjudge1 | Trol (COCI19_trol) | C++98 | 1 ms | 584 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |