結果

問題 No.152 貯金箱の消失
ユーザー steek79steek79
提出日時 2015-12-11 18:04:58
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,151 ms / 5,000 ms
コード長 584 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 6,516 KB
実行使用メモリ 6,228 KB
最終ジャッジ日時 2023-10-13 10:57:59
合計ジャッジ時間 5,643 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,160 KB
testcase_01 AC 12 ms
6,172 KB
testcase_02 AC 11 ms
5,988 KB
testcase_03 AC 12 ms
6,112 KB
testcase_04 AC 24 ms
5,984 KB
testcase_05 AC 24 ms
5,976 KB
testcase_06 AC 36 ms
6,204 KB
testcase_07 AC 185 ms
6,228 KB
testcase_08 AC 1,150 ms
6,012 KB
testcase_09 AC 1,151 ms
5,992 KB
testcase_10 AC 962 ms
5,980 KB
testcase_11 AC 542 ms
5,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
# -*- coding: utf-8 -*-
#ピタゴラス数 (a, b, c) が原始的であるためには、3つのうち2つが互いに素であることが必要十分である。
def gcd(a,b):
    while b:
        a,b = b, a%b
    return a

def lcm(a,b):
    return a*b / gcd(a, b)

L = input()
m = 2
n = 1
ans = 0

while True:
    if gcd(m, n) == 1 and (m-n)%2 == 1:
        length = 4 * (2*m**2 + 2*m*n)
        if length <= L:
            ans += 1
        if length > 5 * L:
            break

    if m - n == 1:
        m += 1
        n = 1
    else:
        n += 1

print ans
0