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<stdio.h>
#include<string.h>
int hash1[]={};
int hash2[]={}; int jud(char a[],int len)
{
if(a[]>=''&&a[]<='')
{
return ; //false代表不合格的进位大整数;
}
if(a[]==''&&len!=)
{
return ;
}
if(a[]==''&&len==)
{
return ;
}
if(a[]>=''&&a[]<'')
{
return ;
}
}
int main()
{
char a[];
int inta[],i,len,temp;
gets(a);
len=strlen(a);
/*将字符串数组转化为对应整数,存入变换的整数数组中*/
for(i=;i<len;i++)
{
inta[i]=a[i]-'';
hash1[inta[i]]++;
}
/*/检测输出
for(i=0;i<len;i++)
{
printf("%d",inta[i]);
}
*/
//检测变化数组内容的数字出现次数;
/**/
// printf("\n");
// for(i=0;i<10;i++)
// {
// printf("%d ",hash1[i]);
// }
/**/
// printf("\n");
int count=;
for(i=len-;i>;i--)
{
temp=inta[i]*+count;
if(temp>=)
{
count=;
}
else{
count=;
}
inta[i]=temp%;
}
inta[]=inta[]*+count;
//将变换数组*2 //判断数组
if( jud(a,len)==)
{ //对*2后的数组中数字出现的次数进行统计;
for(i=;i<len;i++)
{
hash2[inta[i]]++;
}
// for(i=0;i<10;i++)
// {
// printf("%d ",hash2[i]);
// } //比较两hash表是否完全相等
for(i=;i<;i++)
{
if(hash1[i]!=hash2[i])
{
printf("No\n");
for(i=;i<len;i++)
{
printf("%d",inta[i]);
}
return ;
}
}
printf("Yes\n");
for(i=;i<len;i++)
{
printf("%d",inta[i]);
}
} else if(jud(a,len)==)
{
printf("No\n");
for(i=;i<len;i++)
{
printf("%d",inta[i]);
}
}
else
{
printf("No\n");
for(i=;i<len;i++)
{
printf("%d",inta[i]);
}
} return ;
}

最新文章

  1. 移动端性能优化动态加载JS、CSS
  2. 网页中插入swf动画(embed)
  3. Linux_使用Linux之安装jdk 7
  4. linux中deb怎样安装
  5. [PWA] 12. Intro to IndexedDB
  6. Hive 1、什么是Hive,Hive有什么用
  7. Maven java项目管理工具
  8. Protel99SE制作拼板的方法
  9. Lake Counting(poj 2386)
  10. bat文件无法双击运行
  11. CentOS安装Python教程
  12. 12、Python-网络编程
  13. Entity Framework技巧系列之二 - Tip 6 - 8
  14. SVG渐变
  15. Webpack 2 视频教程 009 - 配置 ESLint 实现代码规范自动测试 (上)
  16. Python--urllib3库详解1
  17. hdu4864 Task贪心好题
  18. 四则运算4(Android版)
  19. Git使用六:版本对比
  20. BT原理分析

热门文章

  1. H3C 星型以太网拓扑扩展
  2. JavaScript 按位与和逻辑与
  3. SSM项目整合第一步 注册登陆实现
  4. H3C 帧中继协议栈
  5. CentOS7 network.service loaded failed 处理技巧
  6. H3C调试信息输出的例子
  7. linux 定时器 API
  8. 2018百度之星初赛B - A,D,F
  9. H3C使用ping命令
  10. 【转】AUC(Area Under roc Curve )计算及其与ROC的关系