結果

問題 No.800 四平方定理
ユーザー tpynerivertpyneriver
提出日時 2019-03-18 00:31:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 761 ms / 2,000 ms
コード長 340 bytes
コンパイル時間 913 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 416,792 KB
最終ジャッジ日時 2023-09-22 16:15:54
合計ジャッジ時間 20,035 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 761 ms
415,948 KB
testcase_01 AC 457 ms
416,548 KB
testcase_02 AC 481 ms
416,792 KB
testcase_03 AC 454 ms
416,416 KB
testcase_04 AC 453 ms
416,740 KB
testcase_05 AC 457 ms
416,580 KB
testcase_06 AC 454 ms
416,404 KB
testcase_07 AC 453 ms
416,196 KB
testcase_08 AC 449 ms
416,340 KB
testcase_09 AC 450 ms
416,548 KB
testcase_10 AC 515 ms
416,452 KB
testcase_11 AC 510 ms
416,512 KB
testcase_12 AC 518 ms
416,636 KB
testcase_13 AC 510 ms
416,456 KB
testcase_14 AC 511 ms
416,576 KB
testcase_15 AC 512 ms
416,460 KB
testcase_16 AC 508 ms
416,620 KB
testcase_17 AC 502 ms
416,444 KB
testcase_18 AC 531 ms
416,600 KB
testcase_19 AC 526 ms
416,292 KB
testcase_20 AC 438 ms
415,460 KB
testcase_21 AC 433 ms
415,560 KB
testcase_22 AC 518 ms
416,552 KB
testcase_23 AC 582 ms
416,776 KB
testcase_24 AC 558 ms
416,596 KB
testcase_25 AC 600 ms
416,464 KB
testcase_26 AC 438 ms
415,684 KB
testcase_27 AC 437 ms
415,732 KB
testcase_28 AC 560 ms
416,644 KB
testcase_29 AC 569 ms
416,512 KB
testcase_30 AC 562 ms
416,620 KB
testcase_31 AC 562 ms
416,452 KB
testcase_32 AC 574 ms
416,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

su = [0] * (8*10**6 + 1)
for a in range(1, N+1):
    for b in range(1, N+1):
        su[a*a + b*b] += 1


di = [0] * (8*10**6 + 1)
for c in range(1, N+1):
    for d in range(1, N+1):
        k = c*c - d*d + D
        if k > 0:
            di[c*c - d*d + D] += 1

print(sum([i * j for i, j in zip(su, di)]))
0