結果

問題 No.800 四平方定理
ユーザー pasoconhoshii
提出日時 2019-03-18 00:55:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 582 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 259,516 KB
最終ジャッジ日時 2024-07-08 07:52:33
合計ジャッジ時間 21,108 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 2 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

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(i,N):
        if i == j:
            cnt[ lst[i] + lst[j] ] += 1
        else:
            cnt[ lst[i] + lst[j] ] += 2
        # else:
        #     cnt[ lst[i] + lst[j] ] += 2

ans = 0

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

print(ans)
            
0