= =是道沙茶题,直接模拟即可。。。
1 /************************************************************** 2 Problem: 2134 3 User: rausen 4 Language: C++ 5 Result: Accepted 6 Time:1292 ms 7 Memory:78932 kb 8 ****************************************************************/ 9 10 #include <cstdio> 11 #include <cmath> 12 13 using namespace std; 14 typedef double lf; 15 typedef long long ll; 16 const int N = 10000005; 17 const ll Mod = 100000001; 18 ll n, a, b, c, d[N]; 19 20 inline int read() { 21 int x = 0; 22 char ch = getchar(); 23 while (ch < '0' || '9' < ch) 24 ch = getchar(); 25 while ('0' <= ch && ch <= '9') { 26 x = x * 10 + ch - '0'; 27 ch = getchar(); 28 } 29 return x; 30 } 31 32 int main() { 33 int i; 34 n = read(), a = read(), b = read(), c = read(); 35 for (d[1] = read(), i = 2; i <= n; ++i) 36 d[i] = (d[i - 1] * a + b) % Mod; 37 for (i = 1; i <= n; ++i) 38 d[i] = (d[i] % c) + 1; 39 d[n + 1] = d[1]; 40 lf ans = 0; 41 for (i = 1; i <= n; ++i) 42 if (d[i] <= d[i + 1]) 43 ans += (lf) 1.0 / d[i + 1]; 44 else 45 ans += (lf) 1.0 / d[i]; 46 printf("%.3lf", ans); 47 return 0; 48 }