結果

問題 No.800 四平方定理
ユーザー silversmithsilversmith
提出日時 2019-04-07 20:21:15
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 622 ms / 2,000 ms
コード長 402 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 416,744 KB
最終ジャッジ日時 2023-09-09 23:41:02
合計ジャッジ時間 13,391 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
81,920 KB
testcase_01 AC 95 ms
88,960 KB
testcase_02 AC 96 ms
84,808 KB
testcase_03 AC 93 ms
86,176 KB
testcase_04 AC 93 ms
83,864 KB
testcase_05 AC 92 ms
85,128 KB
testcase_06 AC 98 ms
91,152 KB
testcase_07 AC 97 ms
87,484 KB
testcase_08 AC 97 ms
90,908 KB
testcase_09 AC 99 ms
89,192 KB
testcase_10 AC 343 ms
258,012 KB
testcase_11 AC 363 ms
253,616 KB
testcase_12 AC 356 ms
252,748 KB
testcase_13 AC 331 ms
260,900 KB
testcase_14 AC 338 ms
253,928 KB
testcase_15 AC 336 ms
253,248 KB
testcase_16 AC 359 ms
254,796 KB
testcase_17 AC 362 ms
254,788 KB
testcase_18 AC 368 ms
254,216 KB
testcase_19 AC 367 ms
254,516 KB
testcase_20 AC 75 ms
71,024 KB
testcase_21 AC 75 ms
71,348 KB
testcase_22 AC 368 ms
254,800 KB
testcase_23 AC 622 ms
416,540 KB
testcase_24 AC 595 ms
416,428 KB
testcase_25 AC 613 ms
416,404 KB
testcase_26 AC 78 ms
71,332 KB
testcase_27 AC 73 ms
71,496 KB
testcase_28 AC 593 ms
415,620 KB
testcase_29 AC 601 ms
416,312 KB
testcase_30 AC 596 ms
415,964 KB
testcase_31 AC 576 ms
402,804 KB
testcase_32 AC 557 ms
416,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, D =map(int, input().split())
up = 2*N*N +1
num_xy = [0] * up
for x in range(1,N+1):
    for y in range(1,N+1):
        idx = x*x + y*y -1
        num_xy[idx] = num_xy[idx] +1
num_zw = [0] * up 
for z in range(1,N+1):
    for w in range(1,N+1):
        idx = w*w +D - z*z -1
        if idx > 0 and idx < up: 
            num_zw[idx] = num_zw[idx] +1
print(sum([a*b for (a,b) in zip(num_xy,num_zw)]))
0