結果

問題 No.800 四平方定理
ユーザー tobusakana
提出日時 2022-10-02 17:17:42
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 446 bytes
コンパイル時間 1,479 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 580,980 KB
最終ジャッジ日時 2024-12-25 13:19:00
合計ジャッジ時間 49,731 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other AC * 15 TLE * 12 MLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

N,D = map(int,input().split())

from collections import defaultdict
left = defaultdict(int)
for x in range(1, N + 1):
    for y in range(1, N + 1):
        left[x**2 + y**2] += 1
        
right = defaultdict(int)
for w in range(1, N + 1):
    for z in range(1, N + 1):
        right[w**2 - z**2 + D] += 1
        
ans = 0
for key, value in left.items():
    if key in right:
        ans += right[key] * value
        
print(ans)
        
        
0