推 oin1104: 大師 12/08 21:22
第一個想法居然是沒有想法
我就這樣了
def countTriples(self, n: int) -> int:
rets = 0
for a in range(1, n+1):
for b in range(a, n+1):
if (a**2+b**2)<=(n**2) and (a**2+b**2) == (int(math.sqrt((a**2+b**
2))))**2:
rets += 2
return rets
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.132.58.28 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1765200104.A.045.html