-
Notifications
You must be signed in to change notification settings - Fork 1
/
ANARC08B.cpp
119 lines (96 loc) · 1.88 KB
/
ANARC08B.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// ANARC08B - Adding Sevens
// Author: Tarun Kumar
// E-mail: [email protected]
#include <iostream>
#include <vector>
using namespace std;
long long int convert(long long int n)
{
if(n==63)
return 0;
if(n==10)
return 1;
if(n==93)
return 2;
if(n==79)
return 3;
if(n==106)
return 4;
if(n==103)
return 5;
if(n==119)
return 6;
if(n==11)
return 7;
if(n==127)
return 8;
if(n==107)
return 9;
}
string output(long long int x)
{
if(x==0)
return "063";
if(x==1)
return "010";
if(x==2)
return "093";
if(x==3)
return "079";
if(x==4)
return "106";
if(x==5)
return "103";
if(x==6)
return "119";
if(x==7)
return "011";
if(x==8)
return "127";
if(x==9)
return "107";
}
int main()
{
long long int i,n,j,x,y,p,k,l;
char ch;
string s,tmp;
while(1)
{
cin>>s;
vector<char> v(s.begin(),s.end());
if(v[0]=='B')
break;
tmp="";
x=0;y=0;
for(i=0;i<v.size();i++)
{
if(v[i]=='+')
break;
p=(v[i]-'0')*100+(v[i+1]-'0')*10+(v[i+2]-'0');
i++;i++;
x=x*10+convert(p);
}
// cout<<"x="<<x<<" ";
i++;
for(;i<v.size();i++)
{
if(v[i]=='=')
break;
p=(v[i]-'0')*100+(v[i+1]-'0')*10+(v[i+2]-'0');
i++;i++;
y=y*10+convert(p);
}
// cout<<"y="<<y<<" ";
x=x+y;
// cout<<x<<endl;
tmp="";
while(x>0)
{
tmp=output(x%10)+tmp;
x=x/10;
}
cout<<s<<tmp<<endl;
}
return 0;
}