-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1023.cpp
92 lines (86 loc) · 1.25 KB
/
1023.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
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<iostream>
#include<sstream>
#include<string>
#include<map>
#include<string.h>
using namespace std;
#undef DEBUG
class Big
{
public:
int a[30];
int len;
int newlen;
int bucket1[10];
int bucket2[10];
void read(char s[])
{
int i;
for(i=0;i<10;i++)
bucket1[i]=0;
len=strlen(s);
for(i=0;i<len;i++)
{
a[i]=s[len-i-1]-'0';
bucket1[a[i]]++;
}
}
void dub()
{
int i;
for(i=0;i<len;i++)
{
a[i]*=2;
}
a[len]=0;
for(i=0;i<len;i++)
{
if(a[i]>=10)
{
a[i]=a[i]%10;
a[i+1]++;
}
}
if(a[len] !=0)
newlen=len+1;
else
newlen=len;
for(i=0;i<10;i++)
bucket2[i]=0;
for(i=0;i<newlen;i++)
bucket2[a[i]]++;
}
bool check()
{
for(int i=0;i<10;i++)
if(bucket1[i]!=bucket2[i])
return false;
return true;
}
void print()
{
for(int i=newlen-1;i>=0;i--)
printf("%d",a[i]);
}
};
int main()
{
freopen("input.in","r",stdin);
freopen("output.out","w",stdout);
char buffer[30];
scanf("%s",buffer);
Big b;
b.read(buffer);
b.dub();
if(b.check())
printf("Yes\n");
else
printf("No\n");
b.print();
return 0;
}