結果

問題 No.2979 直角三角形の個数
ユーザー amesyu
提出日時 2024-12-03 12:54:21
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 323 bytes
コンパイル時間 439 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 65,408 KB
最終ジャッジ日時 2024-12-03 12:54:25
合計ジャッジ時間 3,370 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 16 RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

n = int(input())
assert n <= 10**7
ans = 0
sqrt = int(n ** .5) + 1
for b in range(1, sqrt):
    for a in range(b + 1, sqrt):
        p = a**2 + b**2
        if p%4 != 1: continue
        if math.gcd(a, b) != 1: continue
        q = a**2 - b**2
        r = 2 * a * b
        ans += n // (p + q + r)

print(ans)
0