好消息:这一篇没有上古警告!
#include
#include
#include
#include
#include
#include
#include
#define LL long long
using namespace std;
LL n,a,b,c,head,tail,q[1000005],f[1000005],BEGIN[1000005],s[1000005];
double Slope(LL j,LL k)
{return double(f[k]-f[j]+a*(s[k]*s[k]-s[j]*s[j])-b*(s[k]-s[j]))/double(2*a*(s[k]-s[j]));
}
void Solve()
{f[0]=0,head=1,tail=1;//2as单增
for(LL i=1;i<=n;i++)
{while(headSlope(q[tail],i))tail--;
q[++tail]=i;
}
}
void Input()
{scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
s[0]=0;
for(LL i=1;i<=n;i++)
{scanf("%lld",&BEGIN[i]);
s[i]=s[i-1]+BEGIN[i];
}
}
int main()
{Input();
Solve();
printf("%lld\n",f[n]);
return 0;
}
/*
4
-1 10 -20
2 2 3 4
*/
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int cnt=0,ans,wer,n,k,a,b,h[200005]={0},vis[200005],dist[200005],from[200005],stack[200005],D[200005],Maxx[200005],Sec[200005];
int qu[500005];
struct node{int next,to;}edge[400005];
queueq;
void Addedge(int x,int y)
{cnt++,edge[cnt].to=y,edge[cnt].next=h[x],h[x]=cnt;
}
void Input()
{scanf("%d%d",&n,&k);
for(int i=1;iMaxx[x])Sec[x]=Maxx[x],Maxx[x]=Maxx[y]+1;
else if(Maxx[y]+1>Sec[x])Sec[x]=Maxx[y]+1;
}
wer=min(wer,ans-Maxx[x]-Sec[x]+1);
}
void Dp()//链上的DP
{int head=1,tail=1;qu[1]=0;
for(int i=1;i<=stack[0];i++)
{wer=min(wer,ans-(qu[head]+Maxx[stack[i]]-D[stack[i]]-1));
while(head<=tail&&qu[tail]maxx)maxx=dist[i],rec=i;
S=rec;
memset(vis,0,sizeof(vis)),memset(from,0,sizeof(from));
dist[S]=0,from[S]=0;
Dfs(S);
maxx=0;
for(int i=1;i<=n;i++)
if(dist[i]>maxx)maxx=dist[i],rec=i;
ans=2*(n-1)-maxx+1;
wer=999999999;
if(k==1){printf("%d\n",ans);return;}
memset(vis,0,sizeof(vis));
while(!q.empty())q.pop();
int now=rec;
while(now)stack[++stack[0]]=now,vis[now]=1,dist[now]=0,now=from[now];
for(int i=1,j=stack[0];i
#include
#include
#include
#include
#include
#include
#include
#define LL long long
using namespace std;
LL n,ans1,ans2,top;
struct node{LL x,y;double ang;}point[1505],temp[1505];
void Input()
{scanf("%lld",&n);
if(n==3){printf("3.000000\n");exit(0);}
for(LL i=1;i<=n;i++)
{scanf("%lld%lld",&point[i].x,&point[i].y);
}
}
bool Comp(node x,node y)
{return x.ang=0)
{R=R%top+1,num++;
if(R==i)break;
}
ret-=num*(num-1)/2,num--;
}
return ret;
}
void Solve()
{ans1=0;
for(LL i=1;i<=n;i++)
ans1+=Inner(i);
ans2=n*(n-1)*(n-2)*(n-3)/24-ans1;
double wer=(double(2*ans2+ans1))/double(n*(n-1)*(n-2)/6.0);
printf("%.6lf\n",wer+3);
}
int main()
{Input();
Solve();
return 0;
}