1023 Have Fun with Numbers (20 point(s))

版权声明:听说这里让写版权声明~~~ https://blog.csdn.net/m0_37691414/article/details/86659805

#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
const int MAXN = 22;
string s;
int a[MAXN];
int carry, bit, flag;
int main() {
	cin >> s;
	for(int i = s.length() - 1; i >= 0; --i) {
		bit = s[i] - '0';
		a[bit]--;
		int t = bit * 2 + carry;
		carry = t / 10;
		s[i] = t % 10 + '0';
		a[t % 10]++;
	}
	for(int i = 0; i < 10; ++i) if(a[i]) flag = 1;
	if(carry || flag) printf("No\n");
	else printf("Yes\n");
	if(carry) printf("1");
	cout << s;
	return 0;
} 

猜你喜欢

转载自blog.csdn.net/m0_37691414/article/details/86659805
今日推荐