結果

問題 No.800 四平方定理
ユーザー i_takui_taku
提出日時 2023-09-29 10:35:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,575 ms / 2,000 ms
コード長 334 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 189,416 KB
最終ジャッジ日時 2023-09-29 10:35:49
合計ジャッジ時間 22,747 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
78,428 KB
testcase_01 AC 114 ms
80,108 KB
testcase_02 AC 117 ms
79,324 KB
testcase_03 AC 111 ms
79,680 KB
testcase_04 AC 111 ms
79,008 KB
testcase_05 AC 109 ms
79,476 KB
testcase_06 AC 114 ms
80,992 KB
testcase_07 AC 117 ms
80,060 KB
testcase_08 AC 117 ms
80,888 KB
testcase_09 AC 119 ms
80,632 KB
testcase_10 AC 706 ms
157,764 KB
testcase_11 AC 724 ms
166,532 KB
testcase_12 AC 679 ms
166,656 KB
testcase_13 AC 721 ms
158,080 KB
testcase_14 AC 692 ms
166,588 KB
testcase_15 AC 695 ms
166,620 KB
testcase_16 AC 707 ms
166,560 KB
testcase_17 AC 742 ms
166,644 KB
testcase_18 AC 709 ms
166,620 KB
testcase_19 AC 675 ms
166,688 KB
testcase_20 AC 91 ms
71,684 KB
testcase_21 AC 89 ms
71,472 KB
testcase_22 AC 713 ms
166,624 KB
testcase_23 AC 1,482 ms
189,132 KB
testcase_24 AC 1,467 ms
189,216 KB
testcase_25 AC 1,575 ms
189,360 KB
testcase_26 AC 90 ms
71,680 KB
testcase_27 AC 89 ms
71,616 KB
testcase_28 AC 1,433 ms
189,008 KB
testcase_29 AC 1,382 ms
189,416 KB
testcase_30 AC 1,416 ms
189,276 KB
testcase_31 AC 1,265 ms
188,632 KB
testcase_32 AC 1,408 ms
189,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N, D = map(int, input().split())
cnt = defaultdict(int)
for x in range(1, N + 1):
    for y in range(1, N + 1):
        cnt[x**2 + y**2 - D] += 1
ans = 0
for w in range(1, N + 1):
    for z in range(1, N + 1):
        key = w**2 - z**2
        if key in cnt:
            ans += cnt[key]
print(ans)
0