1、题意:这就是说考试的时候抄串了一位能对几个(雾)
2、分析:这是一个期望问题,期望就是平均,E(a+b)=E(a)+E(b),所以我们直接算出每个点能对几个就好,那么就是1/max(a[i],a[i%n+1])就好,最后加起来
#include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std; #define LL long long #define M 10000010 inline int read(){ char ch = getchar(); int x = 0, f = 1; while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); } while('0' <= ch && ch <= '9'){ x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } int a[M]; int main(){ int n, 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; double ans = 0; for(int i = 1; i <= n; i ++){ ans += 1.0 / max(a[i], a[i % n + 1]); } printf("%.3lf\n", ans); return 0; }