結果

問題 No.800 四平方定理
ユーザー tikitaka1201
提出日時 2020-09-16 20:15:19
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 504 bytes
コンパイル時間 346 ms
コンパイル使用メモリ 82,436 KB
実行使用メモリ 274,052 KB
最終ジャッジ日時 2024-06-22 03:31:41
合計ジャッジ時間 25,624 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 TLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
def MI():
    return map(int, input().split())

n,d=MI()

ws=[i+1 for i in range(n)]
xs=[i+1 for i in range(n)]
ys=[i+1 for i in range(n)]
zs=[i+1 for i in range(n)]

wz,xy=[],[]
for i in ws:
    for j in zs:
        wz.append(i**2-j**2+d)
wz=sorted(wz)
for i in xs:
    for j in ys:
        xy.append(i**2+j**2)
xy=sorted(xy)
from bisect import bisect_right, bisect_left

ans=0
for i in xy:
    l=bisect_left(wz, i)
    r=bisect_right(wz, i)
    ans+=r-l
print(ans)
0