結果

問題 No.800 四平方定理
ユーザー tikitaka1201tikitaka1201
提出日時 2020-09-16 20:15:19
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 504 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 85,976 KB
実行使用メモリ 280,796 KB
最終ジャッジ日時 2023-09-04 03:52:13
合計ジャッジ時間 27,351 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
80,864 KB
testcase_01 AC 157 ms
86,320 KB
testcase_02 AC 140 ms
82,948 KB
testcase_03 AC 139 ms
83,988 KB
testcase_04 AC 139 ms
82,040 KB
testcase_05 AC 146 ms
83,948 KB
testcase_06 AC 170 ms
88,464 KB
testcase_07 AC 156 ms
85,016 KB
testcase_08 AC 138 ms
88,540 KB
testcase_09 AC 159 ms
86,852 KB
testcase_10 AC 1,592 ms
256,372 KB
testcase_11 AC 1,866 ms
246,956 KB
testcase_12 AC 1,765 ms
258,264 KB
testcase_13 AC 1,780 ms
257,644 KB
testcase_14 AC 1,900 ms
247,180 KB
testcase_15 AC 1,837 ms
246,908 KB
testcase_16 AC 1,948 ms
247,208 KB
testcase_17 AC 1,651 ms
247,352 KB
testcase_18 AC 1,784 ms
247,368 KB
testcase_19 AC 1,795 ms
247,168 KB
testcase_20 AC 78 ms
70,808 KB
testcase_21 AC 79 ms
70,660 KB
testcase_22 AC 1,780 ms
247,268 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

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