package tax2;
class nonlinear{
int th[]= new int[101];
int c[]= new int[101];
int y[]= new int[101];
int s;
double h;
int n1,n2,q,nx1,nx2;
double c1,l1,u1;
double[][][] ux= new double[101][21][21];
double[][][] wx= new double[101][21][21];
double[][][][] v= new double[101][21][21][101];
int[][][][] er= new int[101][21][21][101];
int[][][][] gotoc= new int[100][21][21][101];
int[][][][] gotoy= new int[100][21][21][101];
int[][][][] gotoq= new int[100][21][21][101];
int qx,es,e1;
int z;
double vs,v1,w1;
int nsc,nsy;
void makedata(){
for (s=1;s<101;s++){
for (n1=-10;n1<11;n1++){
for (n2=-10;n2<11;n2++){
c1=(c[s]+n1)*h;
l1=(double)(y[s]+n2)/th[s];
u1=u(c1,1-l1);
ux[s][n1+10][n2+10]=u1;
}
}
}
for (s=1;s<100;s++){
for (n1=-10;n1<11;n1++){
for (n2=-10;n2<11;n2++){
c1=(c[s]+n1)*h;
l1=(double)(y[s]+n2)/th[s+1];
u1=u(c1,1-l1);
wx[s][n1+10][n2+10]=u1;
}
}
}
for (n1=-10;n1<11;n1++){
for (n2=-10;n2<11;n2++){
for (q=-50;q<51;q++){
v[1][n1+10][n2+10][q+50]=-999;
}
}
}
for (n1=-10;n1<11;n1++){
for (n2=-10;n2<11;n2++){
q=n2-n1;
v[1][n1+10][n2+10][q+50]=ux[1][n1+10][n2+10];
}
}
for (n1=-10;n1<11;n1++){
for (n2=-10;n2<11;n2++){
er[1][n1+10][n2+10][q+50]=0;
}
}
for (s=2;s<100;s++){
for (n1=-10;n1<11;n1++){
for (n2=-10;n2<11;n2++){
for (q=-50;q<51;q++){
u1=ux[s][n1+10][n2+10];
qx=q-n1+n2;
z=0;
if (qx>50)z=100;
if (qx<-50)z=100;
if (z>50)qx=0;
vs=-999;
nsc=0;
nsy=0;
es=999;
for (nx1=-10;nx1<11;nx1++){
for (nx2=-10;nx2<11;nx2++){
v1=u1+v[s-1][nx1+10][nx2+10][qx+50];
w1=wx[s-1][nx1+10][nx2+10];
e1=er[s-1][nx1+10][nx2+10][qx+50];
if(w1>u1)e1=e1+1;
check();
}
}
if (z>50)vs=-999;
gotoc[s][n1+10][n2+10][q+50]=nsc;
gotoy[s][n1+10][n2+10][q+50]=nsy;
gotoq[s][n1+10][n2+10][q+50]=qx;
v[s][n1+10][n2+10][q+50]=vs;
er[s][n1+10][n2+10][q+50]=es;
}
}
}
}
}
void check(){
int h;
h=0;
if(e1<es)h=h+1;
if(v1>-900)h=h+1;
if(h==2)es=e1;
if(h==2)vs=v1;
if(h==2)nsc=n1;
if(h==2)nsy=n2;
h=0;
if(e1==es)h=h+1;
if(v1>vs)h=h+1;
if(h==2)es=e1;
if(h==2)vs=v1;
if(h==2)nsc=n1;
if(h==2)nsy=n2;
}
double u(double c1,double x1){
double u1,c2,x2;
int pp;
pp=0;
c2=c1;
x2=x1;
if (c2<0)pp=100;
if (x2<0)pp=100;
if (x2>1)pp=100;
if (x2==0)pp=100;
if (pp>50)c2=0.5;
if (pp>50)x2=0.5;
u1=Math.log(c2)+Math.log(x2);
if (pp>50)u1=-999;
return u1;
}
}
最終更新:2013年09月30日 06:44