1023 Have Fun with Numbers (20 分)
 

Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number consisting exactly the numbers from 1 to 9, only in a different permutation. Check to see the result if we double it again!

Now you are suppose to check if there are more numbers with this property. That is, double a given number with k digits, you are to tell if the resulting number consists of only a permutation of the digits in the original number.

Input Specification:

Each input contains one test case. Each case contains one positive integer with no more than 20 digits.

Output Specification:

For each test case, first print in a line "Yes" if doubling the input number gives a number that consists of only a permutation of the digits in the original number, or "No" if not. Then in the next line, print the doubled number.

Sample Input:

1234567899

Sample Output:

Yes
2469135798
 #include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
using namespace std;
int Array[];
int main()
{
string num;
cin >> num;
int len = num.size();
int flag = ;
int temp = ;
for (int i = len - ; i >= ; i--)
{
Array[num[i] - '']++;
temp = (num[i] - '') * + flag;
flag = ;
if (temp> )
{
temp %= ;
flag = ;
}
Array[temp]--;
num[i] = '' + temp;
}
int flag1 = ;
for(int i=;i<;i++)
if (Array[i]!=)
{
flag1= ;
break;
}
if (flag1)
{
cout << "No" << endl;
if (flag)
cout << "" << num;
else
cout << num;
}
else
{
cout << "Yes" << endl;
if (flag)
cout << "" << num;
else
cout << num;
} }

最新文章

  1. .net 将List序列化成Json字符串
  2. iOS真机测试碰到错误linker command failed with exit code 1 (use -v to see invocation)
  3. js图形网站
  4. MyEclipse在线安装maven插件最新地址
  5. AgileEAS.NET SOA 中间件平台5.2版本下载、配置学习(二):配置WinClient分布式运行环境
  6. linux tar.gz
  7. [转] Python自动单元测试框架
  8. 利用&lt;JavascriptSerializer类&gt; 进行Json对象的序列化和反序列化
  9. 纯js分页代码(简洁实用)
  10. jQuery1.8以上,ajaxSend,ajaxStart等一系列事件要绑定在document上才有效果
  11. 带有机器人框架的.NET自己主动化測试
  12. DeviceIoControl 直接从磁盘扇区读文件
  13. jq toggle1.9版本后不支持解决方案
  14. shiro(二)自定义realm,模拟数据库查询验证
  15. 呵呵,Python操作MSSQL的帮助类
  16. Linux命令行抓包及包解析工具tshark(wireshark)使用实例解析
  17. Windows 下安装 Memcached
  18. 【CentOS7.0】虚拟机如何实现扩展存储空间
  19. Java 8 中常用的函数式接口
  20. HTML DOM学习

热门文章

  1. plsql乱码问题
  2. openwrt sdk 编译工具 及 hello world
  3. 编译 AR9271 wifi 网卡固件 htc_9271.fw
  4. 【Python】2.12学习笔记 变量
  5. go例子(三) 使用context实现发牌手策略
  6. 【Weiss】【第03章】练习3.11:比较单链表递归与非递归查找元素
  7. 手把手构建LSTM的向前传播(Building a LSTM step by step)
  8. 数据结构和算法:Python实现二分查找(Binary_search)
  9. SQL语句中,如何使用含有if....else...判断语句
  10. JavaScript 模式》读书笔记(4)— 函数2