EularProject 36:2进制和10进制回文数
2015-07-29 23:07
197 查看
华电北风吹
天津大学认知计算与应用重点实验室
完成日期:2015/7/29
Double-base palindromes
Problem 36
The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.
Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.
(Please note that the palindromic number, in either base, may not include leading zeros.)
Answer:
872187
Completed on Wed, 29 Jul 2015, 16:04
天津大学认知计算与应用重点实验室
完成日期:2015/7/29
Double-base palindromes
Problem 36
The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.
Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.
(Please note that the palindromic number, in either base, may not include leading zeros.)
Answer:
872187
Completed on Wed, 29 Jul 2015, 16:04
result=0 for i in range(1,1000000): a=bin(i)[2::] b=a[::-1] if a==b: a=str(i) b=a[::-1] if a==b: result+=i print(result)
相关文章推荐
- 黑马程序员——System类常用方法及流对象操作规律
- Android Audio代码分析 - Audio Strategy
- 【Leetcode】Rotate List
- struts-ajax实现局部刷新分页
- CSS基础-6CSS样式-背景
- 【思维题】uva11300Spreading the Wealth
- Fragment用findViewById得到空值解决办法
- VS字符集设置
- 7月29日学习内容
- 科普小时代---笔记本连接无线受限
- 生产环境下Tengine keepalived tomcat 安装和配置
- 鸟哥的私房菜学习笔记一
- iPhone 文件读写操作
- html中设置<hr/>的长度和粗细等属性
- Centos6.6 安装 Qt4.8.6 + QtCreator2.6.1
- android菜鸟笔记之UI线程阻塞
- XMUT acdream DP专场
- numpy : the difference between row and column vector
- 7-29
- 高质量、免费的PPT图片资源哪里找?