| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 76945 | 胡海峰老师 | 勾股数 | Python3 | Compile Error | 0 MS | 0 KB | 949 | 2024-06-06 12:13:46 |
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(f"{triple[0]} {triple[1]} {triple[2]}") print(total_count) if __name__ == "__main__": main()
File "Main.py", line 24
print(f"{triple[0]} {triple[1]} {triple[2]}")
^
SyntaxError: invalid syntax