题解 | #qcjj寄快递#
qcjj寄快递
https://www.nowcoder.com/practice/229bbec64b6b42e48171bef8f88ada47
对每一项 单独进行考虑:
对于
求导得到
令其等于
可以得到
,考虑
非负,所以
累加即可。
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const LL maxn=1100000,M=998244353,inf=1LL<<62;
LL n,m,x;double ans=0.0;
struct point{double x,y;}a[maxn];
double dis(point A,point B){return sqrt(pow(A.x-B.x,2.0)+pow(A.y-B.y,2.0));}
int main(){
scanf("%lld",&n);
for(LL i=1;i<=n;i++)scanf("%lf%lf",&a[i].x,&a[i].y);
for(LL i=2;i<=n;i++){
double t=dis(a[i-1],a[i]);
double x=log(t*log(2.0))/log(2.0);
x=max(x,0.0);
ans+=2.0*(x+t/pow(2.0,x));
}
printf("%.12lf",ans);
return 0;
}
查看9道真题和解析