链接:http://cogs.pro/cogs/problem/problem.php?pid=1882
题意:你涂串卡了,求你期望对了几个。
妈的水题两分钟……
首先,假rand()出来的数组,a[i]<=a[i+1]的话,a[i]答案一定在a[i+1]中,那么第i+1个对的概率就为1/a[i+1];
反之,a[i]不一定在a[i+1]中,在的概率为a[i+1]/a[i],对的概率为1/a[i]。
闹了半天就是取较大的那个的倒数(╯‵□′)╯︵┻━┻吔屎啦(╯‵□′)╯︵┻━┻
1 #include<iostream>cogs1882
2 #include<cstdio>
3 #include<algorithm>
4 #include<cstring>
5 using namespace std;
6 const int maxn=10000005;
7 int n,A,B,C,a[maxn];
8 int haha()
9 {
10 freopen("nt2011_exp.in","r",stdin);
11 freopen("nt2011_exp.out","w",stdout);
12 scanf("%d%d%d%d%d",&n,&A,&B,&C,a+1);
13 for (int i=2;i<=n;i++)
14 a[i] = ((long long)a[i-1] * A + B) % 100000001;
15 for (int i=1;i<=n;i++)a[i] = a[i] % C + 1;
16 double ans=0;
17 for(int i=1;i<n;i++)ans+=1/(double)max(a[i],a[i+1]);
18 ans+=1/(double)max(a[1],a[n]);
19 printf("%.3lf\n",ans);
20 }
21 int sb=haha();
22 int main(){;}