A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000.Find the product abc. 译文:一个毕达哥拉斯三元数组是由三个自然数组…
flag = 0 for a in range(1,1000): for b in range(a+1,1000): if a*a + b*b == (1000-a-b)**2: print(a,b) flag = 1 break if flag == 1: break print(a*b*(1000-a-b))…
A Pythagorean triplet is a set of three natural numbers, a  b  c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000.Find the product abc. #include<stdio.h> #inclu…
这个比较简单,慢慢进入状态. A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000.Find the product abc. for a in xra…
我是俩循环暴力 看了看给的文档,英语并不好,有点懵,所以找了个中文的博客看了看:勾股数组学习小记.里面有两个学习链接和例题. import math def calc(): for i in range(1,1000): j = i+1 while j <= 1000: c = i*i+j*j c = int(math.sqrt(c)) if i+j+c > 1000: break if i < j < c and i+j+c == 1000 and i*i+j*j == c*c:…
Special subset sums: meta-testing Let S(A) represent the sum of elements in set A of size n. We shall call it a special sum set if for any two non-empty disjoint subsets, B and C, the following properties are true: S(B) ≠ S(C); that is, sums of subse…
Special subset sums: optimum Let S(A) represent the sum of elements in set A of size n. We shall call it a special sum set if for any two non-empty disjoint subsets, B and C, the following properties are true: S(B) ≠ S(C); that is, sums of subsets ca…
Summation of primes Problem 10 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. The code resemble : import math limit = 2000000 crosslimit = int(math.sqrt(limit)) #sieve = [False] * limit sieve =…
题目的大意很简单 做法的话. 我们就枚举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, 1…
这题略水啊 首先观察一下. 10 ^ x次方肯定是x + 1位的 所以底数肯定小于10的 那么我们就枚举1~9为底数 然后枚举幂级数就行了,直至不满足题目中的条件即可break cnt = 0 for i in range(1, 10): e = 1 while True: if len(str(i**e)) != e: break e += 1 cnt += 1 print cnt…