Python实现Pat 1023. Have Fun with Numbers (20)
来源:互联网 发布:江苏语音网络系统注册 编辑:程序博客网 时间:2024/05/23 05:09
题目
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
解答
s1=input()num1=int(s1)num2=num1*2s2=str(num2)li1 = list(s1)li2 = list(s2)li1.sort()li2.sort()if li1==li2: print ('Yes')else: print('No')print(num2)
- Python实现Pat 1023. Have Fun with Numbers (20)
- 【PAT】1023. Have Fun with Numbers (20)
- PAT: 1023. Have Fun with Numbers (20)
- PAT 1023. Have Fun with Numbers (20)
- PAT 1023. Have Fun with Numbers (20)
- PAT 1023. Have Fun with Numbers (20)
- PAT 1023. Have Fun with Numbers (20)
- pat 1023. Have Fun with Numbers (20)
- PAT 1023. Have Fun with Numbers (20)
- PAT 1023. Have Fun with Numbers (20)
- pat 1023. Have Fun with Numbers (20)
- PAT 1023. Have Fun with Numbers (20)
- PAT Have fun with numbers (Python)
- PAT PAT 1023. Have Fun with Numbers (20)
- pat 1023. Have Fun with Numbers
- PAT-A 1023. Have Fun with Numbers
- PAT 1023. Have Fun with Numbers
- 【PAT】1023. Have Fun with Numbers
- lombok简介
- 学习jvm一
- SAP表格维护生成器生成数据表维护视图程序
- unity3d 实时影子shadowCascades 4倍抗锯齿 动态设置之坑
- C++ builder 管道的应用 实例 红色字体
- Python实现Pat 1023. Have Fun with Numbers (20)
- SQLServer批量插数据
- 拼写错误检测(动态规划法)
- VL6180X传感器驱动
- 使用Visual Studio Code,.net Core 2.0进行CodeFirst
- TCP/IP 5层协议
- leetcode219[easy]----Contains Duplicate II
- numpy的基本操作
- vue-router相同的地址,如何刷新数据