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 file 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<string>
using namespace std;
int main() {
int i = ;
int j = ;
int len;
int temp;
string num;
//判断是否为输入的副本
bool is_dup = true;
int judge[];
//保存输出结果
int result[];
//保存进位
int counter[]; cin >> num;
len = num.length(); for (i = ; i < ; i++) {
counter[i] = ;
judge[i] = ;
}
//计算输出结果
for (i = len - ; i >= ; i--) {
temp = (num[i] - '');
judge[temp]++;
temp = temp * + counter[i];
result[j++] = temp % ;
if (i != )
counter[i - ] = temp / ;
else {
result[j++] = temp / ;
}
}
if (result[j - ] != )
len = j; for (i = ; i < len; i++) {
judge[result[i]]--;
} for (i = ; i < ; i++) {
if (judge[i] != ) {
is_dup = false;
}
} if (is_dup)
cout << "Yes" << endl;
else
cout << "No" << endl; for (j = len - ; j >= ; j--) {
cout << result[j];
}
return ;
}

00-自测4. Have Fun with Numbers的更多相关文章

  1. pat00-自测4. Have Fun with Numbers (20)

    00-自测4. Have Fun with Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yu ...

  2. 数据结构练习 00-自测4. Have Fun with Numbers (20)

    Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, wit ...

  3. 自测-4 Have Fun with Numbers

    Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, wit ...

  4. PTA 自测-4 Have Fun with Numbers

    #include<iostream> #include<string> #include<cstring> #include<vector> using ...

  5. PAT自测_打印沙漏、素数对猜想、数组元素循环右移、数字加倍重排、机器洗牌

    -自测1. 打印沙漏() 本题要求你写个程序把给定的符号打印成沙漏的形状.例如给定17个“*”,要求按下列格式打印 ***** *** * *** ***** 所谓“沙漏形状”,是指每行输出奇数个符号 ...

  6. LC 357. Count Numbers with Unique Digits

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  7. Using the Task Parallel Library (TPL) for Events

    Using the Task Parallel Library (TPL) for Events The parallel tasks library was introduced with the ...

  8. JavaScript+svg绘制的一个动态时钟

    结果图: 代码如下: <!DOCTYPE html> <html> <head> <title>动态时钟</title> </head ...

  9. WeQuant交易策略—NATR

    策略名称:NATR策略关键词:规范真实波幅.价格突破. NATR,是对ATR指标进行了标准化.主要应用于了解价格的震荡幅度和节奏,在窄幅整理行情中用于寻找突破时机.本策略在当前价格高于之前价格一定倍数 ...

随机推荐

  1. Kubernetes(k8s)入门、单机版安装、kuberctl指令、k8s服务实例

    1.切换root .关闭centos自带的防火墙 # systemctl disable firewalld # systemctl stop firewalld .安装etcd和kubernetes ...

  2. (转)WebSocket学习

    石墨文档:https://shimo.im/docs/3UkyOPJvmj4f9EAP/ (二期)17.即时通讯技术websocket [课程17]java We...实现.xmind0.1MB [课 ...

  3. 160CrackMe练手 001

    peid判断无壳,打开输入伪码注册,根据报错od查找字符串 接下来定位到字符串周边代码 0042FA15 |. 8D55 F0 lea edx,[local.4] 0042FA18 |. 8B83 D ...

  4. 给斐讯K1刷机并拨号e信(湖北地区测试无问题)

    ◆购买斐讯k1路由器 路由器在天猫京东斐讯旗舰店都有售卖,我买的价格是159,不过有一张铃铛卡,一个月之后返还160元,相当于0元购 ◆路由器刷不死Breed 1.路由与电脑有线连接好,输入192.1 ...

  5. P2517 [HAOI2010]订货

    思路 费用流水题 对每月拆点,入点向出点连cap=ui的边,s向入点连cost=di的边,i的入点向i+1的入点连cap=S的边即可 代码 #include <cstdio> #inclu ...

  6. 用RAR将多个文件夹一次性压缩为多个对应zip文件

    选中要压缩的所有文件夹.右键,选“添加到压缩文件...”,弹出的菜单如下图: 点击菜单栏“文件”.在“把每个文件都单独压缩文件中”选中,才可以单独创建压缩.如下图

  7. Anaconda使用命令

    参考的地址:https://zhuanlan.zhihu.com/p/32925500 conda 基础命令: 1.验证conda已被安装 conda --version 终端上就会以conda 版本 ...

  8. 【C#】可空类型 NullAble<T>

    在实际编写代码时候 ,  会遇到很多场景, 需要将值置成空, 比如发货日期, 有可能是没有. 在没有可空类型之前, 程序都是用 魔值, 即为一个minValue或者常量, 来代表这个值为空, 也有用一 ...

  9. Python-ConfigParser获取配置项名称大小写问题

    C:\Python27\Lib\ConfigParser.py: def optionxform(self, optionstr): return optionstr.lower() 会将配置文件中的 ...

  10. HDU 4315 Climbing the Hill(阶梯博弈)

    http://acm.hdu.edu.cn/showproblem.php?pid=4315 题意:由上至下有多个格子,最顶端的是山顶,有多个球,其中有一个球是king,每次可以将球向上移动任意个格子 ...