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.1
2
3
4
5Sample Input:
1234567899
Sample Output:
Yes
2469135798
1 | #include<iostream> |
代码不难,即使在自己电脑上调,也就改了一次后就直接往PAT上测试了,然后就AC了,今晚运气不错加上前四道自测题不难,基本上没有超过第二遍的,最后一道自测题还没看,11点多开始写自测题1,到现在不到两小时写出前四道,对我这新手来说还算一般。最后一道自测题等考完试在看吧。该洗洗睡了!
测试结果如下:
| 测试点 | 结果 | 用时(ms) | 内存(kB) | 得分/满分 |
|---|---|---|---|---|
| 0 | 答案正确 | 1 | 264 | 3/3 |
| 1 | 答案正确 | 1 | 180 | 2/2 |
| 2 | 答案正确 | 1 | 308 | 2/2 |
| 3 | 答案正确 | 1 | 180 | 2/2 |
| 4 | 答案正确 | 1 | 264 | 2/2 |
| 5 | 答案正确 | 1 | 308 | 3/3 |
| 6 | 答案正确 | 1 | 308 | 3/3 |
| 7 | 答案正确 | 1 | 180 | 3/3 |