-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1023.cpp
48 lines (47 loc) · 806 Bytes
/
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
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
string str;
string ans;
int main(){
cin >> str;
int num = str.length();
//reverse的用法
reverse(str.begin(),str.end());
int i= 0;
int yuan[10] = {0};
int jie[10] = {0};
int k = 0;
int sign = 0;
int y = 0;
for(i = 0;i < num;i++){
y = str[i] - '0';
yuan[y] ++;
k = y * 2 + sign;
sign = 0;
if(k >= 10){
jie[k - 10] ++;
ans += ('0' + k - 10);
sign = 1;
}else{
jie[k] ++;
ans += ('0' + k);
}
}
if(sign == 1){
ans += '1';
}
reverse(ans.begin(),ans.end());
for(i = 0 ;i < 10;i++){
if(jie[i] != yuan[i]){
printf("No\n");
cout << ans;
return 0;
}
}
printf("Yes\n");
cout << ans;
return 0;
}