結果

問題 No.152 貯金箱の消失
ユーザー 👑 KazunKazun
提出日時 2021-02-12 00:59:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 404 ms / 5,000 ms
コード長 426 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 78,672 KB
最終ジャッジ日時 2023-09-25 14:49:46
合計ジャッジ時間 3,888 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,272 KB
testcase_01 AC 80 ms
75,296 KB
testcase_02 AC 72 ms
71,272 KB
testcase_03 AC 81 ms
75,428 KB
testcase_04 AC 154 ms
77,396 KB
testcase_05 AC 154 ms
77,276 KB
testcase_06 AC 171 ms
77,320 KB
testcase_07 AC 226 ms
78,032 KB
testcase_08 AC 400 ms
78,672 KB
testcase_09 AC 404 ms
78,576 KB
testcase_10 AC 368 ms
78,572 KB
testcase_11 AC 294 ms
78,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(x,y):
    if (x,y) in Memo:
        return Memo[(x,y)]
    if x%y:
        return gcd(y,x%y)
    else:
        return y

L=int(input())
Memo={}
Mod=1000003

X=0
m=1
while 4*m*m<=L:
    for n in range(1,m):
        if gcd(m,n)!=1:
            continue

        if (m%2)^(n%2)==0:
            continue

        a=m*m-n*n
        b=2*m*n
        c=m*m+n*n

        if 4*(a+b+c)<=L:
            X+=1
    m+=1

print(X%Mod)
0