結果

問題 No.800 四平方定理
ユーザー neterukunneterukun
提出日時 2019-06-10 07:22:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 495 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 99,560 KB
最終ジャッジ日時 2024-04-15 20:17:01
合計ジャッジ時間 28,599 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
17,408 KB
testcase_01 AC 79 ms
13,096 KB
testcase_02 AC 69 ms
11,904 KB
testcase_03 AC 69 ms
11,816 KB
testcase_04 AC 60 ms
11,904 KB
testcase_05 AC 67 ms
11,944 KB
testcase_06 AC 92 ms
13,352 KB
testcase_07 AC 80 ms
13,092 KB
testcase_08 AC 91 ms
13,096 KB
testcase_09 AC 86 ms
13,348 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 29 ms
10,752 KB
testcase_21 AC 28 ms
10,752 KB
testcase_22 TLE -
testcase_23 TLE -
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())

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

ans = 0
for i in range(1, n + 1):
    for j in range(1, n + 1):
        if d + i**2 - j**2 in li1:
            ans += li1[d + i**2 - j**2]
print(ans)
0