結果

問題 No.152 貯金箱の消失
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-27 16:51:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 575 ms / 5,000 ms
コード長 382 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-09 03:16:55
合計ジャッジ時間 3,440 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 32 ms
10,880 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 32 ms
10,880 KB
testcase_04 AC 38 ms
10,880 KB
testcase_05 AC 39 ms
10,880 KB
testcase_06 AC 45 ms
10,880 KB
testcase_07 AC 116 ms
10,880 KB
testcase_08 AC 560 ms
10,880 KB
testcase_09 AC 575 ms
10,880 KB
testcase_10 AC 463 ms
10,752 KB
testcase_11 AC 267 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd as g


def gcd(a, b, c):
    return g(a, g(b, c))


L = int(input())
if L < 48:
    print(0)
    exit()

L //= 4
ans = 0
for m in range(1, int(L ** 0.5) + 10):
    for n in range(1, m):
        if 2 * m * (m + n) > L:
            break
        a = m*m - n*n
        b = 2*m*n
        c = m*m - n*n
        if gcd(a, b, c) == 1:
            ans += 1


print(ans)
0