2134: 单选错位|概率与期望

相邻的两个题单独来算

相邻的两个题期望得分为1/(max(a[i],a[i+1]))

#include<cstdio>
#include<cstdlib>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int a[10000005],n,A,B,C;
double ans;
int main()
{
	scanf("%d%d%d%d%d",&n,&A,&B,&C,a+1); 
	for (int i=2;i<=n;i++) a[i] = ((long long)a[i-1] * A + B) % 100000001; 
	for (int i=1;i<=n;i++) a[i] = a[i] % C + 1; 
	a[n+1]=a[1];
	for(int i=1;i<=n;i++)
	{
		double x=max(a[i],a[i+1]);
		ans+=1/x;
	}
	printf("%.3lf",ans);
	return 0;
}


你可能感兴趣的:(概率与期望)