class game{
public static void main(String args[]){
double startc,startk;
double pp;
double c1,c2,c3;
double cx,k1;
double a,beta;
double r1;
int s,t;
double[] tk=new double[101];
double[] c=new double[101];
for (t=1;t<101;t++){
tk[t]=0.2;
}
a=0.33;
beta=0.95;
startk=10;
c[1]=seekc(tk,startk);
t=1;
k1=startk;
while(t<100){
k1=k1+Math.pow(k1,a)-c[t];
r1=(1-tk[t+1])*a*Math.pow(k1,a-1);
c[t+1]=c[t]*(beta*(1+r1));
System.out.println(c[t]);
t=t+1;
}
}
static double seekc(double[] tk,double startk){
double startc,c1,c2,c3;
int s;
double pp;
c1=0.1;
c2=10;
s=0;
while(s<50){
c3=(c1+c2)/2;
startc=c3;
pp=check(tk,startc,startk);
if(pp<50)c1=c3;
if(pp>50)c2=c3;
s=s+1;
}
return c1;
}
static double check(double[] tk,double startc,double startk){
int t,t1;
double pp;
double k1,cx,r1;
double a,beta;
a=0.33;
beta=0.95;
cx=startc;
k1=startk;
t=1;
pp=0;
while(t<200){
k1=k1+Math.pow(k1,a)-cx;
t1=t+1;
if (t1>100)t1=100;
r1=(1-tk[t1])*a*Math.pow(k1,a-1);
cx=cx*(beta*(1+r1));
if (k1<0)pp=100;
t=t+1;
}
return pp;
}
}
最終更新:2010年01月23日 00:56