Codeforces 1155

1155 D

题意

给你 \(n,x\) 和一个数组 \(a\) ,现在你可以把 \(a\) 的至多一个子区间的所有元素乘上 \(x\) ,问 \(a\) 数组最终的美丽值。一个数组的美丽值为 \(\max(0,该数组的最大子段和)\)\((n\le 10^5,所有数\le 10^9)\)

Examples

input
5 -2
-3 8 -2 1 -6
output
22
input
12 -3
1 3 3 7 1 3 3 7 1 3 3 7
output
42
input
5 10
-1 -2 -3 -4 -5
output
0

显然dp。
dp[i][0/1/2]表示枚举到第 \(i\) 个数,还没有使用乘法/正在使用乘法/乘法使用完毕的最大子段和。

1155 E

题意

有一个多项式,次数 \(\le 10\) ,现在你有50次询问机会,每次询问一个 \(x\) 返回 \(f(x)\) ,要你求出该多项式的零点。保证有且只有一个。\(\% 1000003\) 意义下进行 \((0\le 所有数\le 1000002)\)

Examples

input

1000002

0
output
? 0

? 1

! 1
input

5

2

1

output
? 2

? 1

? 0

! -1

先询问11次把这个多项式的表达式弄出来(高斯消元/拉格朗日/其它乱搞),然后暴力0~1000002往里代即可。

猜你喜欢

转载自www.cnblogs.com/BlogOfchc1234567890/p/10806137.html
今日推荐