結果

問題 No.2979 直角三角形の個数
ユーザー lif4635
提出日時 2024-12-03 00:34:30
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 437 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 931,076 KB
最終ジャッジ日時 2024-12-03 00:35:38
合計ジャッジ時間 68,216 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 TLE * 1 MLE * 1
other AC * 9 TLE * 10 MLE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import cache
from math import isqrt

@cache
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

n = int(input())
#定数倍を考える
# #sqrt(n)以上のとき
ans = 0
for p in range(1,isqrt(n) + 1):
    f = p%2 + 1
    #遇奇の不一致
    for q in range(f,p,2):
        r = 2 * p * (p + q)
        if gcd(p,q) != 1:
            continue
        ans += n//r #この倍数まで大丈夫

print(ans) 
0