Problem 4
Problem 4
# Problem_4
"""
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
找到两个三位数数字相乘能得到的最大的回文数字
"""
palindroms = {}
for x in range(100, 1000):
for y in range(100, 1000):
num = str(x * y)
length = len(num)
mid = length // 2
formar = num[:mid]
latter = num[mid:][::-1]
if not length % 2 == 0:
latter = num[mid+1:][::-1]
if formar == latter:
value = str(x) + '*' + str(y)
palindroms[int(num)] = value print(palindroms)
max_key = max(palindroms)
max_value = palindroms[max_key]
print(max_key, '==>', max_value)
Problem 4的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
随机推荐
- 一见钟情Sublime
打开 preferences -> Setting-User,加入下面代码 { "font_size": 14, "ignored_packages": ...
- linux c 操作utmp 和 wtmp 文件接口
/var/run/utmp 保存当前在本系统中的用户信息 /var/log/wtmp 保存登陆过本系统的用户信息 他们保存的信息是基于结构体 struct utmp 的(/usr/include/bi ...
- 关于Java特种兵下冊
<Java特种兵 下冊>这本书一直没出.至上冊出版近1年以来,每周会有非常多小伙伴发私信或邮件问起我下冊出版的事情,纵使眼下有非常多无奈,小胖还是初步决定准备写下冊. 下冊内容(下冊的内容 ...
- arcgis server10.2.2公布地图基础服务的详细步骤
1.直接打开制作好的.mxd文档,比方这里: 2.打开mxd文档之后.打开菜单:file-share as -services 弹出地图公布服务的界面: 点击publish之后,耐心的等待一段时间,地 ...
- Aizu/Aoj 0033 Ball
题目大意: 有编号1到10共10个球,从上方丢下去,入口处可以选择进入左边或者右边,最后10个球全部落下去后如果左右两侧都是从小到大的顺序,则输出YES:否则输出NO. 题目原本的标签枚举,复杂度是2 ...
- luogu3942 将军令 贪心
题目大意:给你一个地图(树),共有1~n个驿站(点),编号分别为1~n,告诉你第ui个驿站与第vi个驿站有一条长度为1的路(边),每个小队(可以放在任意驿站上)最多有k的覆盖长度,问最多要放置多少个小 ...
- luogu1447 能量采集
题目大意 给出m,n,对于每一个整数x∈[1,m],y∈[1,n]都有一点(x,y).处理每个点所需要的能量为2*k+1,k为该点到原点经过的点的数量(不包括该点本身).求处理所有点所需要的能量和. ...
- 查找python项目依赖并生成requirements.txt——pipreqs 真是很好用啊
查找python项目依赖并生成requirements.txt 转自:http://blog.csdn.net/orangleliu/article/details/60958525 一起开发项目的时 ...
- div向右偏移设置 css让div靠右移一定距离
转自:https://www.thinkcss.com/shili/1372.shtml div对象盒子向右偏移设置,使用css让div靠右一定距离-div向右移教程实例篇 div向右偏移一定距离,可 ...
- org.springframework.beans.factory.config.PropertyPlaceholderConfigurer的systemPropertiesModeName属性
转自:https://www.cnblogs.com/huqianliang/p/5673701.html 使用PropertyPlaceholderConfigurer类载入外部配置 在Spring ...