不会做%%http://blog.csdn.net/doom_bringer/article/details/50428503
1 #include<bits/stdc++.h> 2 #define LL long long 3 #define LD long double 4 #define N 100005 5 using namespace std; 6 inline int ra() 7 { 8 int x=0,f=1; char ch=getchar(); 9 while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();} 10 while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();} 11 return x*f; 12 } 13 double f[1005],p[1005]; 14 double ksm(double a, int p) 15 { 16 double ans=1; 17 for (;p;p>>=1,a*=a) 18 if (p&1) 19 ans*=a; 20 return ans; 21 } 22 int main() 23 { 24 freopen("tribbles.in","r",stdin); 25 freopen("tribbles.out","w",stdout); 26 int T=ra(); 27 for (int t=1; t<=T; t++) 28 { 29 int n=ra(),k=ra(),m=ra(); 30 for (int i=0; i<n; i++) scanf("%lf",&p[i]); 31 memset(f,0,sizeof(f)); 32 f[0]=0; f[1]=p[0]; 33 for (int i=2; i<=m; i++) 34 for (int j=0; j<n; j++) 35 f[i]+=p[j]*ksm(f[i-1],j); 36 printf("Case #%d: %.7lf ",t,ksm(f[m],k)); 37 } 38 return 0; 39 }