小学数学题......
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #define mem(a,b) memset(a,b,sizeof(a)) 5 #define dd double 6 #define ll long long 7 using namespace std; 8 int minn(int a,int b){return a<b?a:b;} 9 const int N=10000100; 10 const int M=1000000100; 11 12 int n,A,B,C; 13 int a[N]; 14 double ans; 15 16 int main(){ 17 scanf("%d%d%d%d%d",&n,&A,&B,&C,a+1); 18 for(int i=2;i<=n;++i) 19 a[i]=((ll)a[i-1]*A+B)%100000001; 20 for(int i=1;i<=n;++i) 21 a[i]=a[i]%C+1; 22 23 for(int i=1;i<n;++i) 24 ans+=minn(a[i],a[i+1])*((1.0/(dd)a[i])*(1.0/(dd)a[i+1])); 25 ans+=minn(a[1],a[n])*((1.0/(dd)a[1])*(1.0/(dd)a[n])); 26 printf("%.3lf",ans); 27 //while(1); 28 return 0; 29 } 30