码迷,mamicode.com
首页 > 其他好文 > 详细

bzoj 2134

时间:2016-03-20 13:03:29      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

水概率DP,ANS=sigma(min(a[i],a[i-1])/(a[i]*a[i-1]))

技术分享
 1 #include<bits/stdc++.h>
 2 #define inc(i,l,r) for(int i=l;i<=r;i++)
 3 #define dec(i,l,r) for(int i=l;i>=r;i--)
 4 #define link(x) for(edge *j=h[x];j;j=j->next)
 5 #define mem(a) memset(a,0,sizeof(a))
 6 #define inf 1e9
 7 #define ll long long
 8 #define succ(x) (1<<x)
 9 #define lowbit(x) (x&(-x))
10 #define NM 10000000+5
11 using namespace std;
12 int read(){
13     int x=0,f=1;char ch=getchar();
14     while(!isdigit(ch)){if(ch==-)f=-1;ch=getchar();}
15     while(isdigit(ch))x=x*10+ch-0,ch=getchar();
16     return x*f;
17 }
18 int n,A,B,C,a[NM];
19 double s;
20 int main(){
21     freopen("data.in","r",stdin);
22     scanf("%d%d%d%d%d",&n,&A,&B,&C,a+1);
23     for (int i=2;i<=n;i++) a[i] = ((long long)a[i-1] * A + B) % 100000001;
24     for (int i=1;i<=n;i++) a[i] = a[i] % C + 1;
25     a[n+1]=a[1];
26     inc(i,2,n+1)s+=(double)min(a[i],a[i-1])/a[i]/a[i-1];
27     printf("%.3lf\n",s);
28     return 0;
29 }
View Code

 

bzoj 2134

标签:

原文地址:http://www.cnblogs.com/onlyRP/p/5297453.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!