[C语言][PTA][数据结构] 自测-4 Have Fun with Numbers (20 point(s))

By | September 30, 2019

这是 拼题A(PTA)《中国大学MOOC-陈越、何钦铭-数据结构-起步能力自测题》的习题。原题在 https://pintia.cn/problem-sets/17/problems/263 (侵删)
本人的答案仅供交流学习,请勿用于当作答案来提交!

题目描述:

自测-4 Have Fun with Numbers (20 point(s))
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

我的答案:


© 2019, wpmaster. All rights reserved.

鉴于本人的相关知识储备以及能力有限,本博客的观点或者描述如有错漏或是有考虑不周到的地方还请多多包涵,也欢迎指正,一起学习,共同进步。

0