【COGS 1478】麻球繁衍

题目传送门:http://cogs.top/cogs/problem/problem.php?pid=1487

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

const int MAXN = 1000+9;

int n,m;
double w,p[MAXN],vout;

inline int read(){
	char c=getchar(); int buf=0,f=1;
	while (c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0'){buf=buf*10+c-'0';c=getchar();}
	return buf*f;
}

int main(){
	freopen("tribbles.in","r",stdin);
	freopen("tribbles.out","w",stdout);
	for (int T=1,TT=read();T<=TT;T++){
		n = read(), w = read(); m = read(); 
		for (int i=0;i<n;i++) scanf("%lf",&p[i]);
		vout = p[0];
		for (int k=2;k<=m;k++) {
			double tmp = 0;
			for (int i=0;i<n;i++) tmp += p[i]*pow(vout,i);
			vout = tmp; 
		}
		printf("Case #%d: %.7lf\n",T,pow(vout, w));
	} 
	return 0;
} 

One thought to “【COGS 1478】麻球繁衍”

Leave a Reply

Your email address will not be published. Required fields are marked *