結果

問題 No.800 四平方定理
ユーザー brthyyjpbrthyyjp
提出日時 2020-03-29 03:05:44
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 444 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 86,264 KB
実行使用メモリ 337,460 KB
最終ジャッジ日時 2023-08-30 18:33:03
合計ジャッジ時間 29,565 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
78,844 KB
testcase_01 AC 94 ms
83,876 KB
testcase_02 AC 92 ms
80,944 KB
testcase_03 AC 92 ms
82,400 KB
testcase_04 AC 92 ms
80,376 KB
testcase_05 AC 93 ms
81,840 KB
testcase_06 AC 99 ms
86,444 KB
testcase_07 AC 94 ms
83,020 KB
testcase_08 AC 99 ms
86,428 KB
testcase_09 AC 97 ms
83,928 KB
testcase_10 AC 883 ms
219,992 KB
testcase_11 AC 943 ms
248,340 KB
testcase_12 AC 934 ms
248,428 KB
testcase_13 AC 889 ms
222,152 KB
testcase_14 AC 937 ms
248,224 KB
testcase_15 AC 955 ms
248,524 KB
testcase_16 AC 952 ms
248,388 KB
testcase_17 AC 970 ms
248,512 KB
testcase_18 AC 935 ms
248,444 KB
testcase_19 AC 936 ms
248,432 KB
testcase_20 AC 68 ms
70,964 KB
testcase_21 AC 68 ms
70,852 KB
testcase_22 AC 958 ms
248,376 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 72 ms
70,804 KB
testcase_27 AC 68 ms
70,812 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 AC 1,735 ms
282,652 KB
testcase_32 TLE -
権限があれば一括ダウンロードができます

ソースコード

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