Run ID:76946

提交时间:2024-06-06 12:14:49

def is_pythagorean_triple(a, b, c): return a ** 2 + b ** 2 == c ** 2 def find_pythagorean_triples(max_num): pythagorean_triples = [] for a in range(1, max_num + 1): for b in range(a, max_num + 1): for c in range(b, max_num + 1): if is_pythagorean_triple(a, b, c): sorted_triple = (a, b, c) # sorted_triple.sort() pythagorean_triples.append(sorted_triple) return pythagorean_triples def main(): max_num = 100 # Change this value to adjust the upper limit pythagorean_triples = find_pythagorean_triples(max_num) # unique_triples = set(pythagorean_triples) # total_count = len(unique_triples) total_count = len(pythagorean_triples) for triple in pythagorean_triples: print( "{} {} {}".format(triple[0],triple[1],triple[2])) print(total_count) if __name__ == "__main__": main()