-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1867.cpp
More file actions
66 lines (59 loc) · 898 Bytes
/
1867.cpp
File metadata and controls
66 lines (59 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main(){
bool t1=true,t2=true;
int v,i;
unsigned long long res1=0,res2=0;
while(1){
string st1,st2;
cin>>st1>>st2;
if(st1.length()==1 && st2.length()==1 && st1[0]=='0' && st2[0]=='0')
return 0;
for(i=0;i<st1.length();i++){
v=st1[i]-'0';
res1=res1+v;
}
if(res1>9){
while(1){
string st3 = to_string(res1);
res1=0;
for(i=0;i<st3.length();i++){
v=st3[i]-'0';
res1=res1+v;
}
if(res1<=9)
break;
}
}
for(i=0;i<st2.length();i++){
v=st2[i]-'0';
res2=res2+v;
}
if(res2>9){
while(1){
string st4 = to_string(res2);
res2=0;
for(i=0;i<st4.length();i++){
v=st4[i]-'0';
res2=res2+v;
}
if(res2<=9)
break;
}
}
if(res1>res2)
printf("1\n");
else{
if(res2>res1)
printf("2\n");
else{
printf("0\n");
}
}
res1=res2=0;
t1=true;
t2=true;
}
}