結果

問題 No.800 四平方定理
コンテスト
ユーザー pasoconhoshii
提出日時 2019-03-18 00:24:37
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 449 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 292 ms
コンパイル使用メモリ 21,540 KB
実行使用メモリ 182,232 KB
最終ジャッジ日時 2026-08-12 11:09:12
合計ジャッジ時間 29,597 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other AC * 12 TLE * 9 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

from collections import defaultdict 
cnt = defaultdict(int)


lst = [ i**2 for i in range(1, N+1)]

for i in range(N):
    for j in range(N):
        # if i == j:
        cnt[ lst[i] + lst[j] ] += 1
        # else:
        #     cnt[ lst[i] + lst[j] ] += 2

ans = 0

for i in range(N):
    for j in range(N):
        x,y = lst[i], lst[j]
        # if i == j : 
        ans += cnt[ y+D - x ]

print(ans)
            
0