-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathA1023.cpp
68 lines (62 loc) · 1.13 KB
/
A1023.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
#include <cstdio>
#include <cstring>
using namespace std;
struct BigInt{
int digit[25], len;
BigInt() : len(0) {
memset(digit, 0, sizeof(digit));
}
} a, c;
BigInt transfer(char str[]){
BigInt c;
c.len = strlen(str);
for(int i = 0; i < c.len; ++i){
c.digit[i] = str[c.len - i - 1] - '0';
}
return c;
}
BigInt multi(const BigInt &a, int b){
BigInt c;
int carry = 0;
for(int i = 0; i < a.len; ++i){
int temp = a.digit[i] * b + carry;
c.digit[c.len++] = temp % 10;
carry = temp / 10;
}
while(carry != 0){
c.digit[c.len++] = carry % 10;
carry /= 10;
}
return c;
}
void print(const BigInt &a){
for(int i = a.len - 1; i >= 0; --i){
printf("%d", a.digit[i]);
}
}
bool check(const BigInt &a, const BigInt &b){
int num1[11] = {0}, num2[11] = {0};
if(a.len != b.len) return false;
else{
for(int i = 0; i < a.len; ++i){
++num1[a.digit[i]];
++num2[b.digit[i]];
}
for(int i = 0; i < 11; ++i){
if(num1[i] != num2[i]) return false;
}
return true;
}
}
int main(){
char str[25];
scanf("%s", str);
a = transfer(str);
c = multi(a, 2);
if(check(a, c)){
printf("Yes\n");
}else{
printf("No\n");
}
print(c);
}