Project Euler problem 62
2013-09-29 23:55
232 查看
题目的大意很简单
做法的话。
我们就枚举1~10000的数的立方,
然后把这个立方中的有序重新排列,生成一个字符串s, 然后对于那些符合题目要求的肯定是生成同一个字符串的。
然后就可以用map来搞了
这里偷懒用了python
做法的话。
我们就枚举1~10000的数的立方,
然后把这个立方中的有序重新排列,生成一个字符串s, 然后对于那些符合题目要求的肯定是生成同一个字符串的。
然后就可以用map来搞了
这里偷懒用了python
import string dic = {} def getstr(n): sn = str(n) arr = [] for c in sn: arr.append(c) arr.sort() return ''.join(arr) for i in xrange(1, 10000): s = getstr(i**3) if s in dic: dic[s] += 1 else: dic[s] = 1 a = [] for d in dic: if dic.get(d) == 5: a.append(d) k = min(a) for i in xrange(1, 10000): s = getstr(i**3) if dic[s] == 5: print i, i**3
相关文章推荐
- Project Euler problem 62
- Project Euler problem 6
- Project Euler problem 17
- Project Euler problem 27
- Project Euler problem 38
- Project Euler problem 49
- Project Euler Problem 19
- project euler Problem 36
- http://projecteuler.net/problem=26 [Answer:983]
- Project Euler -> problem 7
- Project Euler Problem 16
- project euler problem 14
- Project Euler Problem 47 Distinct primes factors
- Project Euler Problem 21
- Project Euler Problem 75
- Project Euler problem 7
- Project Euler problem 18
- Project Euler problem 28
- Project Euler problem 39
- Project Euler problem 50