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 b1;
double[] tk=new double[101];
double[] c=new double[101];
for (t=1;t<101;t++){
tk[t]=0.1;
}
a=0.33;
beta=0.95;
startk=10;
startc=seekc(tk,startk);
b1=bud(tk,startc,startk);
System.out.println(b1);
}
static double bud(double[] tk,double startc,double startk){
double[] c=new double[101];
double[] r=new double[101];
double[] tax=new double[101];
double k1,r1,b1;
double a,beta,gov;
double value;
int t;
a=0.33;
beta=0.95;
gov=0.05;
k1=startk;
c[1]=startc;
t=1;
while(t<100){
tax[t]=tk[t]*a*Math.pow(k1,a);
k1=k1+Math.pow(k1,a)-c[t]-gov;
r1=(1-tk[t+1])*a*Math.pow(k1,a-1);
r[t+1]=r1;
c[t+1]=c[t]*(beta*(1+r1));
t=t+1;
}
t=1;
b1=0;
value=1;
while(t<100){
b1=b1+(tax[t]-gov)*value;
value=value/(1+r[t+1]);
t=t+1;
}
return b1;
}
static double wel(double[] tk,double startc,double startk){
double[] c=new double[101];
double k1,r1,swel;
double a,beta,gov;
int t;
a=0.33;
beta=0.95;
gov=0.05;
k1=startk;
c[1]=startc;
t=1;
while(t<100){
k1=k1+Math.pow(k1,a)-c[t]-gov;
r1=(1-tk[t+1])*a*Math.pow(k1,a-1);
c[t+1]=c[t]*(beta*(1+r1));
t=t+1;
}
swel=Math.log(c[1]);
for (t=2;t<99;t++){
swel=swel+Math.pow(beta,t-1)*Math.log(c[t]);
}
swel=swel+Math.pow(beta,98)*Math.log(c[99])/(1-beta);
return swel;
}
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,gov;
double a,beta;
a=0.33;
beta=0.95;
gov=0.05;
cx=startc;
k1=startk;
t=1;
pp=0;
while(t<200){
k1=k1+Math.pow(k1,a)-cx-gov;
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日 19:53