結果

問題 No.152 貯金箱の消失
ユーザー matsu7874matsu7874
提出日時 2015-10-27 11:50:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 615 ms / 5,000 ms
コード長 372 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,740 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2023-10-11 04:19:40
合計ジャッジ時間 3,168 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,784 KB
testcase_01 AC 17 ms
7,972 KB
testcase_02 AC 17 ms
7,864 KB
testcase_03 AC 17 ms
7,808 KB
testcase_04 AC 22 ms
7,920 KB
testcase_05 AC 23 ms
7,928 KB
testcase_06 AC 28 ms
7,868 KB
testcase_07 AC 105 ms
7,812 KB
testcase_08 AC 598 ms
7,952 KB
testcase_09 AC 615 ms
7,932 KB
testcase_10 AC 470 ms
7,956 KB
testcase_11 AC 273 ms
7,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(a, b):
    # 最小公倍数
    while b > 0:
        a, b = b, a % b
    return a

L = int(input())
L = L // 4
cnt = 0
for m in range(1, int(L**0.5)+1):
    for n in range(m - 1, 0, -2):
        if gcd(m,n) != 1:
            continue
        a = m * m - n * n
        b = 2 * m * n
        c = m * m + n * n
        if a+b+c <= L:
            cnt += 1
print(cnt)
0