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 ...
随机推荐
- 使用 F# 列表
使用 F# 列表 在 C# 中使用 F# 的列表,是全然可能的,可是,我建议不要用,由于,仅仅要再做一点,就会使事情在 C# 看来更加自然.比如,把列表转换成数组非常easy.用List.toArra ...
- ural 1005 Stone Pile
这是道01背包题 ,尽管背包不会 ,可是还是看出来了,递推公式写啊写没写出来,后来一同学说是dfs.这我就開始了A了, 题意是给你n个重量是Wn的石头 让你放到两个包里面.看他们两个差值最小, ...
- 读取url中某个值
url="http://test.plus.1course.cn/Task/Display?id=25942" print(url) result=url.split('/')[- ...
- HDU 5308 I Wanna Become A 24-Point Master
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5308 题面: I Wanna Become A 24-Point Master Time Limit ...
- Codeforces Round #244 (Div. 2)D (后缀自己主动机)
Codeforces Round #244 (Div. 2)D (后缀自己主动机) (标号为0的节点一定是null节点,不管怎样都不能拿来用,切记切记,以后不能再错了) 这题用后缀自己主动机的话,对后 ...
- 对Java单继承的弥补——接口
接口主要用来实现多重继承,它是常量和方法的集合,这些方法只有声明没有实现,即接口本身是抽象的,系统默认用abstract修饰. 1.接口的定义: public interface A{ int A=1 ...
- c19---指针和字符串
// // main.c // 指针和字符串 // // Created by xiaomage on 15/6/14. // Copyright (c) 2015年 xiaomage. All ri ...
- nyoj--635--Oh, my goddess(dfs)
Oh, my goddess 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Shining Knight is the embodiment of justice an ...
- poj--2239--Selecting Courses(最大匹配)
Selecting Courses Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9782 Accepted: 4400 ...
- poj--2553--The Bottom of a Graph (scc+缩点)
The Bottom of a Graph Time Limit : 6000/3000ms (Java/Other) Memory Limit : 131072/65536K (Java/Oth ...