結果

問題 No.152 貯金箱の消失
ユーザー titiatitia
提出日時 2022-03-21 00:12:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 717 ms / 5,000 ms
コード長 362 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 227,812 KB
最終ジャッジ日時 2024-04-16 17:22:07
合計ジャッジ時間 10,091 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 708 ms
227,812 KB
testcase_01 AC 704 ms
227,636 KB
testcase_02 AC 699 ms
227,428 KB
testcase_03 AC 692 ms
227,676 KB
testcase_04 AC 705 ms
227,680 KB
testcase_05 AC 710 ms
227,688 KB
testcase_06 AC 714 ms
227,684 KB
testcase_07 AC 708 ms
227,804 KB
testcase_08 AC 717 ms
227,676 KB
testcase_09 AC 710 ms
227,684 KB
testcase_10 AC 699 ms
227,800 KB
testcase_11 AC 703 ms
227,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# ピタゴラス数の列挙式、知らず。
# 検索するしかなさそうですね。

from math import gcd

N=int(input())
N//=4
LIST=set()

for m in range(1,2*10**3):
    for n in range(1,m):
        if gcd(m,n)==1 and m>n and m%2!=n%2:
            LIST.add((m*m-n*n,2*m*n,m*m+n*n))

ANS=0
for a,b,c in LIST:
    if a+b+c<=N:
        ANS+=1

print(ANS)
0