結果

問題 No.800 四平方定理
ユーザー lumefflux
提出日時 2019-03-17 22:46:38
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 444 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 397,540 KB
最終ジャッジ日時 2024-07-08 01:06:39
合計ジャッジ時間 4,946 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 10 TLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N, D = map(int, input().split())
r1 = []
r2 = []
d1 = defaultdict(list)
d2 = defaultdict(list)
ans = 0
for x in range(1, N + 1):
    for y in range(1, N + 1):
        s = x**2 + y**2
        d1[str(s)].append([x, y])
for z in range(1, N + 1):
    for w in range(1, N + 1):
        if w**2 - z**2 + D > 1:
            s = d1.get(str(w**2 - z**2 + D))
            if s:
                ans += len(s)
print(ans)
0