当前位置: 代码迷 >> 综合 >> 1023 Have Fun with Numbers (20 分)
  详细解决方案

1023 Have Fun with Numbers (20 分)

热度:89   发布时间:2023-12-05 07:42:51.0

1023 Have Fun with Numbers (20 分)

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;int main()
{string s;vector<int>a;cin>>s;for(int i=s.size()-1;i>=0;i--)//逆向存储 {a.push_back(s[i]-'0');}vector<int>b;int t=0;//进位 for(int i=0;i<a.size();i++){int sum=a[i]+a[i]+t;b.push_back(sum%10);t=sum/10;} if(t)b.push_back(t);vector<int>c = b;sort(a.begin(),a.end());sort(c.begin(),c.end());if(a==c)puts("Yes");else puts("No");for(int i=b.size()-1;i>=0;i--){cout<<b[i];}return 0;
}