https://www.luogu.com.cn/problem/P1297
思路
https://blog.csdn.net/SSL_ZYC/article/details/87979931
#include <cstdio>
#include <iostream>
using namespace std;
const int N=10000010;
int n,a[N];
double ans;
void init() //题目给出的生成数据的方法
{
int A,B,C;
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;
}
int main()
{
init();
a[n+1]=a[1]; //第1题写第n题的答案
for (int i=1;i<=n;i++)
ans+=1.0/max(a[i],a[i+1]);
printf("%0.3lf",ans);
return 0;
}