自测-4 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 orig

这篇博客讨论了一个有趣的数学现象:当一个9位数如123456789被翻倍后,其结果仍然是由原数字的数字组成的,只是顺序不同。博主提出了一种检查给定数字是否具有此属性的方法,并提供了两种实现思路:通过排序比较列表和使用`collections.Counter`来分析字符出现次数。博客包含输入输出规范、样例以及源代码。
最低0.47元/天 解锁文章

6239

被折叠的 条评论
为什么被折叠?



