結果

問題 No.152 貯金箱の消失
ユーザー yaoshimaxyaoshimax
提出日時 2015-02-16 00:38:53
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,155 ms / 5,000 ms
コード長 409 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 6,652 KB
実行使用メモリ 6,224 KB
最終ジャッジ日時 2023-09-06 01:32:54
合計ジャッジ時間 4,792 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,920 KB
testcase_01 AC 12 ms
6,124 KB
testcase_02 AC 11 ms
5,940 KB
testcase_03 AC 12 ms
6,036 KB
testcase_04 AC 23 ms
6,168 KB
testcase_05 AC 24 ms
6,104 KB
testcase_06 AC 34 ms
6,064 KB
testcase_07 AC 174 ms
5,928 KB
testcase_08 AC 1,146 ms
6,224 KB
testcase_09 AC 1,155 ms
5,984 KB
testcase_10 AC 890 ms
6,040 KB
testcase_11 AC 490 ms
5,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
L=int(raw_input())
mod=1000003
triLen=L/4

def gcd(a,b):
    if a > b:
        return gcd(b,a)
    if b%a==0:
        return a
    return gcd(b%a,a)

ans = 0
for n in range(1, int(math.sqrt(triLen))+1 ):
    for m in range(n+1, int(math.sqrt(triLen-n*n))+1 ):
        if gcd(m,n)==1 and (m-n)%2==1 and 2*m*m+2*m*n<=triLen:
            #print m*m+n*n,2*m*n,m*m-n*n
            ans+=1
print ans%mod
0