結果

問題 No.800 四平方定理
ユーザー neterukunneterukun
提出日時 2019-06-10 07:22:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 923 ms / 2,000 ms
コード長 495 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 233,088 KB
最終ジャッジ日時 2024-04-15 20:17:22
合計ジャッジ時間 14,185 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
64,384 KB
testcase_01 AC 60 ms
66,688 KB
testcase_02 AC 58 ms
66,560 KB
testcase_03 AC 58 ms
66,432 KB
testcase_04 AC 57 ms
65,664 KB
testcase_05 AC 60 ms
66,560 KB
testcase_06 AC 63 ms
67,584 KB
testcase_07 AC 63 ms
66,560 KB
testcase_08 AC 60 ms
67,328 KB
testcase_09 AC 63 ms
67,968 KB
testcase_10 AC 384 ms
164,992 KB
testcase_11 AC 403 ms
176,444 KB
testcase_12 AC 435 ms
182,016 KB
testcase_13 AC 411 ms
175,744 KB
testcase_14 AC 457 ms
181,888 KB
testcase_15 AC 448 ms
181,888 KB
testcase_16 AC 455 ms
182,200 KB
testcase_17 AC 466 ms
181,888 KB
testcase_18 AC 456 ms
181,632 KB
testcase_19 AC 404 ms
175,616 KB
testcase_20 AC 38 ms
52,096 KB
testcase_21 AC 37 ms
52,096 KB
testcase_22 AC 456 ms
182,272 KB
testcase_23 AC 871 ms
232,900 KB
testcase_24 AC 858 ms
233,088 KB
testcase_25 AC 908 ms
232,804 KB
testcase_26 AC 40 ms
52,352 KB
testcase_27 AC 39 ms
51,840 KB
testcase_28 AC 793 ms
232,848 KB
testcase_29 AC 814 ms
232,704 KB
testcase_30 AC 888 ms
232,704 KB
testcase_31 AC 738 ms
232,960 KB
testcase_32 AC 923 ms
232,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, d = map(int, input().split())

li1 = {}
for x in range(1, n + 1):
    for y in range(x + 1, n + 1):
        if x**2 + y**2 not in li1:
            li1[x**2 + y**2] = 2
        else:
            li1[x**2 + y**2] += 2
for x in range(1, n + 1):
    if x**2 + x**2 not in li1:
        li1[x**2 + x**2] = 1
    else:
        li1[x**2 + x**2] += 1

ans = 0
for i in range(1, n + 1):
    for j in range(1, n + 1):
        if d + i**2 - j**2 in li1:
            ans += li1[d + i**2 - j**2]
print(ans)
0