結果

問題 No.800 四平方定理
ユーザー syunsukesyunsuke
提出日時 2019-09-23 18:49:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,580 ms / 2,000 ms
コード長 526 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 81,608 KB
実行使用メモリ 254,996 KB
最終ジャッジ日時 2023-10-19 08:14:32
合計ジャッジ時間 22,734 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
68,676 KB
testcase_01 AC 68 ms
71,624 KB
testcase_02 AC 63 ms
69,732 KB
testcase_03 AC 64 ms
70,288 KB
testcase_04 AC 62 ms
69,236 KB
testcase_05 AC 65 ms
70,292 KB
testcase_06 AC 70 ms
73,452 KB
testcase_07 AC 66 ms
70,920 KB
testcase_08 AC 67 ms
73,436 KB
testcase_09 AC 69 ms
71,624 KB
testcase_10 AC 732 ms
229,988 KB
testcase_11 AC 798 ms
230,184 KB
testcase_12 AC 781 ms
230,184 KB
testcase_13 AC 800 ms
229,920 KB
testcase_14 AC 782 ms
230,184 KB
testcase_15 AC 865 ms
230,184 KB
testcase_16 AC 786 ms
230,184 KB
testcase_17 AC 793 ms
230,184 KB
testcase_18 AC 750 ms
230,184 KB
testcase_19 AC 778 ms
230,184 KB
testcase_20 AC 40 ms
53,404 KB
testcase_21 AC 39 ms
53,404 KB
testcase_22 AC 825 ms
230,184 KB
testcase_23 AC 1,580 ms
254,896 KB
testcase_24 AC 1,411 ms
254,892 KB
testcase_25 AC 1,491 ms
254,908 KB
testcase_26 AC 39 ms
53,404 KB
testcase_27 AC 39 ms
53,404 KB
testcase_28 AC 1,351 ms
254,916 KB
testcase_29 AC 1,407 ms
254,908 KB
testcase_30 AC 1,449 ms
254,912 KB
testcase_31 AC 1,208 ms
254,996 KB
testcase_32 AC 1,465 ms
254,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

D=dict()
N,M=map(int,input().split())

for w in range(1,N+1):
    for z in range(w,N+1):
        if z==w:
            if M not in D:
                D[M]=1
            else:
                D[M]+=1
        elif z**2-w**2+M in D:
            D[w**2-z**2+M]+=1
            D[z**2-w**2+M]+=1
        else:
            D[z**2-w**2+M]=1
            D[w**2-z**2+M]=1
#print(D)
ans=0
for x in range(1,N+1):
    for y in range(1,N+1):
        if x**2+y**2 in D:
            ans+=D[x**2+y**2]
#print(x**2,y**2,x**2+y**2,ans)
print(ans)
0