这题可能存在 x1=x2 的情况,所以我使用了一种很奇怪的方法:
double slope(int a,int b)
{
int x1=q[a],x2=q[b];
int y1=dp[a]+A*q[a]*q[a]-B*q[a],y2=dp[b]+A*q[b]*q[b]-B*q[b];
return 1.0*(y1-y2+eps)/(x1-x2+eps);
}
这样会错三个点,但是
double slope(int a,int b)
{
int x1=q[a],x2=q[b];
int y1=dp[a]+A*q[a]*q[a]-B*q[a],y2=dp[b]+A*q[b]*q[b]-B*q[b];
return 1.0*(y1-y2+eps)/(x1-x2-eps);
}
这样可以AC
请问一下 dalao 们,这样子处理斜率不存在的情况能否用在其他题目上,以及为什么这处改动可以影响最终的结果
求解答qwq