結果

問題 No.800 四平方定理
ユーザー lloyzlloyz
提出日時 2022-11-03 13:26:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,716 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 258,956 KB
最終ジャッジ日時 2023-09-24 22:55:33
合計ジャッジ時間 24,802 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
78,636 KB
testcase_01 AC 90 ms
81,800 KB
testcase_02 AC 90 ms
79,976 KB
testcase_03 AC 90 ms
80,560 KB
testcase_04 AC 83 ms
79,544 KB
testcase_05 AC 88 ms
80,644 KB
testcase_06 AC 91 ms
83,532 KB
testcase_07 AC 89 ms
81,012 KB
testcase_08 AC 91 ms
83,528 KB
testcase_09 AC 89 ms
81,868 KB
testcase_10 AC 711 ms
203,140 KB
testcase_11 AC 759 ms
216,516 KB
testcase_12 AC 773 ms
216,620 KB
testcase_13 AC 785 ms
203,080 KB
testcase_14 AC 789 ms
216,648 KB
testcase_15 AC 831 ms
216,724 KB
testcase_16 AC 788 ms
216,684 KB
testcase_17 AC 811 ms
216,672 KB
testcase_18 AC 816 ms
216,584 KB
testcase_19 AC 773 ms
216,496 KB
testcase_20 AC 67 ms
71,408 KB
testcase_21 AC 67 ms
71,376 KB
testcase_22 AC 693 ms
216,684 KB
testcase_23 AC 1,577 ms
258,608 KB
testcase_24 AC 1,573 ms
258,464 KB
testcase_25 AC 1,716 ms
258,388 KB
testcase_26 AC 68 ms
71,308 KB
testcase_27 AC 67 ms
71,140 KB
testcase_28 AC 1,471 ms
258,956 KB
testcase_29 AC 1,484 ms
258,668 KB
testcase_30 AC 1,556 ms
258,628 KB
testcase_31 AC 1,398 ms
240,500 KB
testcase_32 AC 1,664 ms
258,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

counter = dict()
for w in range(1, n + 1):
    for z in range(1, n + 1):
        res = w**2 - z**2
        if counter.get(res, None) is None:
            counter[res] = 1
        else:
            counter[res] += 1

ans = 0
for x in range(1, n + 1):
    for y in range(1, n + 1):
        res = x**2 + y**2 - d
        if counter.get(res, None) is not None:
            ans += counter[res]
print(ans)
0