結果

問題 No.800 四平方定理
ユーザー Ryushi-techRyushi-tech
提出日時 2020-08-28 09:00:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 282 ms / 2,000 ms
コード長 318 bytes
コンパイル時間 1,147 ms
コンパイル使用メモリ 86,760 KB
実行使用メモリ 232,660 KB
最終ジャッジ日時 2023-08-08 18:01:39
合計ジャッジ時間 8,824 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
232,100 KB
testcase_01 AC 126 ms
232,224 KB
testcase_02 AC 122 ms
232,368 KB
testcase_03 AC 121 ms
232,432 KB
testcase_04 AC 119 ms
232,544 KB
testcase_05 AC 121 ms
232,356 KB
testcase_06 AC 126 ms
232,500 KB
testcase_07 AC 128 ms
232,316 KB
testcase_08 AC 125 ms
232,564 KB
testcase_09 AC 118 ms
232,548 KB
testcase_10 AC 183 ms
232,476 KB
testcase_11 AC 225 ms
232,448 KB
testcase_12 AC 198 ms
232,584 KB
testcase_13 AC 197 ms
232,548 KB
testcase_14 AC 215 ms
232,468 KB
testcase_15 AC 197 ms
232,448 KB
testcase_16 AC 195 ms
232,500 KB
testcase_17 AC 190 ms
232,544 KB
testcase_18 AC 194 ms
232,576 KB
testcase_19 AC 194 ms
232,564 KB
testcase_20 AC 113 ms
227,108 KB
testcase_21 AC 113 ms
227,140 KB
testcase_22 AC 202 ms
232,600 KB
testcase_23 AC 279 ms
232,232 KB
testcase_24 AC 276 ms
232,488 KB
testcase_25 AC 282 ms
232,588 KB
testcase_26 AC 113 ms
227,384 KB
testcase_27 AC 111 ms
227,292 KB
testcase_28 AC 268 ms
232,560 KB
testcase_29 AC 272 ms
232,444 KB
testcase_30 AC 271 ms
232,468 KB
testcase_31 AC 255 ms
232,660 KB
testcase_32 AC 262 ms
232,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, D = map(int, input().split())
lim = 2 * 10 ** 7
base = lim // 2
res = [0] * lim

for i in range(1, n + 1):
    for j in range(1, n + 1):
        res[i ** 2 + j ** 2 + base] += 1

cnt = 0
for i in range(1, n + 1):
    for j in range(1, n + 1):
        d = D - i ** 2 + j ** 2
        cnt += res[base + d]
print(cnt)
0