結果

問題 No.152 貯金箱の消失
コンテスト
ユーザー tktk_snsn
提出日時 2020-12-27 16:51:01
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 393 ms / 5,000 ms
コード長 382 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 530 ms
コンパイル使用メモリ 20,700 KB
実行使用メモリ 15,452 KB
最終ジャッジ日時 2026-04-17 16:43:12
合計ジャッジ時間 5,822 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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