結果

問題 No.800 四平方定理
ユーザー brthyyjpbrthyyjp
提出日時 2020-03-29 03:09:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 444 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 154,876 KB
最終ジャッジ日時 2023-08-30 18:33:32
合計ジャッジ時間 5,429 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
16,168 KB
testcase_01 AC 98 ms
13,072 KB
testcase_02 AC 72 ms
11,808 KB
testcase_03 AC 77 ms
11,920 KB
testcase_04 AC 69 ms
11,836 KB
testcase_05 AC 78 ms
11,944 KB
testcase_06 AC 114 ms
15,616 KB
testcase_07 AC 91 ms
12,992 KB
testcase_08 AC 117 ms
15,572 KB
testcase_09 AC 102 ms
13,164 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

d2 = {}
for z in range(1, n+1):
    for w in range(1, n+1):
        s = z**2-w**2
        if s in d2:
            d2[s] += 1
        else:
            d2[s] = 1

ans = 0
for k in d1.keys():
    if d-k in d2:
        ans += d1[k]*d2[d-k]
print(ans)
0