結果

問題 No.800 四平方定理
ユーザー hogeandfugahogeandfuga
提出日時 2019-03-17 22:11:38
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,868 ms / 2,000 ms
コード長 350 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 86,924 KB
実行使用メモリ 267,624 KB
最終ジャッジ日時 2023-09-22 07:02:21
合計ジャッジ時間 28,318 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
81,304 KB
testcase_01 AC 129 ms
86,668 KB
testcase_02 AC 121 ms
82,924 KB
testcase_03 AC 123 ms
85,544 KB
testcase_04 AC 120 ms
82,992 KB
testcase_05 AC 121 ms
84,648 KB
testcase_06 AC 127 ms
89,020 KB
testcase_07 AC 124 ms
85,704 KB
testcase_08 AC 130 ms
89,056 KB
testcase_09 AC 126 ms
86,556 KB
testcase_10 AC 872 ms
260,232 KB
testcase_11 AC 904 ms
259,984 KB
testcase_12 AC 899 ms
260,868 KB
testcase_13 AC 878 ms
251,216 KB
testcase_14 AC 925 ms
260,284 KB
testcase_15 AC 957 ms
260,360 KB
testcase_16 AC 936 ms
260,384 KB
testcase_17 AC 947 ms
260,344 KB
testcase_18 AC 921 ms
260,088 KB
testcase_19 AC 872 ms
260,356 KB
testcase_20 AC 93 ms
71,308 KB
testcase_21 AC 94 ms
71,692 KB
testcase_22 AC 948 ms
260,212 KB
testcase_23 AC 1,855 ms
267,404 KB
testcase_24 AC 1,832 ms
267,516 KB
testcase_25 AC 1,766 ms
257,704 KB
testcase_26 AC 94 ms
71,432 KB
testcase_27 AC 97 ms
71,492 KB
testcase_28 AC 1,796 ms
267,308 KB
testcase_29 AC 1,809 ms
267,624 KB
testcase_30 AC 1,868 ms
267,560 KB
testcase_31 AC 1,642 ms
259,756 KB
testcase_32 AC 1,868 ms
267,540 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(x, n+1):
        if x == y:
            cnt[x**2+y**2] += 1
        else:
            cnt[x**2+y**2] += 2

ans = 0
for z in range(1, n+1):
    for w in range(1, n+1):
        ans += cnt[w**2 + d - z**2]
print(ans)
0