結果

問題 No.800 四平方定理
ユーザー ayaoni
提出日時 2020-11-27 03:23:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,546 ms / 2,000 ms
コード長 461 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 267,480 KB
最終ジャッジ日時 2024-07-23 21:18:58
合計ジャッジ時間 20,674 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import defaultdict
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,D = MI()

count = defaultdict(int)
for i in range(1,N+1):
    for j in range(i,N+1):
        a = i**2+j**2
        if i == j:
            count[a] += 1
        else:
            count[a] += 2

ans = 0
for i in range(1,N+1):
    for j in range(1,N+1):
        b = -i**2+j**2+D
        if b >= 2:
            ans += count[-i**2+j**2+D]

print(ans)
0