アットウィキロゴ

ミス 最適所得税

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][11][11]; 
double[][][] wx= new double[101][11][11];
double[][][][] v= new double[101][11][11][21];
int[][][][] er= new int[101][11][11][21];
 
int[][][][] gotoc= new int[100][11][11][21]; 
int[][][][] gotoy= new int[100][11][11][21]; 
int[][][][] gotoq= new int[100][11][11][21]; 
 
int qx,es,e1;
int z;
double vs,v1,w1;
int nsc,nsy;
 
double[][] endv=new double[11][11]; 
int[][] endc=new int[11][11]; 
int[][] endy=new int[11][11]; 
int[][] endq=new int[11][11]; 
int[][] ende=new int[11][11]; 
 
int[] opc= new int[101]; 
int[] opy= new int[101]; 
int[] opq= new int[101]; 
 
 
void makedata(){ 
 
 for (s=1;s<101;s++){ 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
c1=(c[s]+n1)*h; 
l1=(double)(y[s]+n2)/th[s]; 
u1=u(c1,1-l1);   
ux[s][n1+5][n2+5]=u1; 
} 
} 
} 
 
 
 for (s=1;s<100;s++){ 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
c1=(c[s]+n1)*h; 
l1=(double)(y[s]+n2)/th[s+1]; 
u1=u(c1,1-l1);   
wx[s][n1+5][n2+5]=u1; 
} 
} 
} 
 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
for (q=-10;q<11;q++){ 
v[1][n1+5][n2+5][q+10]=-999; 
} 
} 
}  
 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
q=n2-n1; 
v[1][n1+5][n2+5][q+10]=ux[1][n1+5][n2+5]; 
} 
} 
 
 
 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
er[1][n1+5][n2+5][q+10]=0; 
} 
} 
 
 
for (s=2;s<100;s++){ 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
for (q=-10;q<11;q++){ 
u1=ux[s][n1+5][n2+5]; 
qx=q+n1-n2; 
z=0; 
if (qx>10)z=100;   
if (qx<-10)z=100;   
if (z>50)qx=0;   
vs=-999; 
nsc=0; 
nsy=0;  
es=999;
for (nx1=-5;nx1<6;nx1++){ 
for (nx2=-5;nx2<6;nx2++){  
v1=u1+v[s-1][nx1+5][nx2+5][qx+10];    
if(z>50)v1=-999;
w1=wx[s-1][nx1+5][nx2+5];
e1=er[s-1][nx1+5][nx2+5][qx+10];
if(w1>u1)e1=e1+1;
check();
} 
} 
gotoc[s][n1+5][n2+5][q+10]=nsc; 
gotoy[s][n1+5][n2+5][q+10]=nsy; 
gotoq[s][n1+5][n2+5][q+10]=qx; 
v[s][n1+5][n2+5][q+10]=vs; 
er[s][n1+5][n2+5][q+10]=es; 
}
}
}
}
 
 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
u1=ux[100][n1+5][n2+5]; 
qx=n1-n2; 
vs=-999; 
nsc=0; 
nsy=0; 
es=9999;
for (nx1=-5;nx1<6;nx1++){ 
for (nx2=-5;nx2<6;nx2++){ 
v1=u1+v[99][nx1+5][nx2+5][qx+10]; 
e1=er[99][nx1+5][nx2+5][qx+10];
if (wx[99][nx1+5][nx2+5]>u1)e1=e1+1;
check();
} 
} 
endc[n1+5][n2+5]=nsc; 
endy[n1+5][n2+5]=nsy; 
endq[n1+5][n2+5]=qx; 
endv[n1+5][n2+5]=vs; 
ende[n1+5][n2+5]=es; 
} 
} 
 
int hx;
 
vs=-999; 
es=999;
nsc=0; 
nsy=0; 
for (n1=-5;n1<6;n1++){ 
for (n2=-5;n2<6;n2++){ 
hx=0;
if (endv[n1+5][n2+5]>vs)hx=hx+1;
if (ende[n1+5][n2+5]==es)hx=hx+1;        
if (hx==2)nsc=n1;  
if (hx==2)nsy=n2;   
if (hx==2)vs=endv[n1+5][n2+5];   
if (ende[n1+5][n2+5]<es)nsy=n2;
if (ende[n1+5][n2+5]<es)nsc=n1;
if (ende[n1+5][n2+5]<es)vs=endv[n1+5][n2+5];
if (ende[n1+5][n2+5]<es)es=ende[n1+5][n2+5];
 
 
} 
} 
 
int j;
 
System.out.println(es);
System.out.println(vs);
 
opc[100]=nsc; 
opy[100]=nsy; 
opc[99]=endc[opc[100]+5][opy[100]+5]; 
opy[99]=endy[opc[100]+5][opy[100]+5]; 
opq[99]=endq[opc[100]+5][opy[100]+5]; 
 
for (j=1;j<99;j++){ 
s=99-j; 
opc[s]=gotoc[s+1][opc[s+1]+5][opy[s+1]+5][opq[s+1]+10]; 
opy[s]=gotoy[s+1][opc[s+1]+5][opy[s+1]+5][opq[s+1]+10]; 
opq[s]=gotoq[s+1][opc[s+1]+5][opy[s+1]+5][opq[s+1]+10]; 
} 
 
int e;
 
e=0; 
for (s=1;s<101;s++){ 
e=e+opc[s]*opc[s]+opy[s]*opy[s]; 
} 
for (s=1;s<101;s++){ 
c[s]=c[s]+opc[s]; 
y[s]=y[s]+opy[s]; 
} 
 
 
 
 
}
void check(){    
int hx;
hx=0;
if(e1<es)hx=hx+1;
if(v1>-900)hx=hx+1;
if(hx==2)es=e1;
if(hx==2)vs=v1;
if(hx==2)nsc=n1;
if(hx==2)nsy=n2;
hx=0;
if(e1==es)hx=hx+1;
if(v1>vs)hx=hx+1;
if(hx==2)es=e1;
if(hx==2)vs=v1;
if(hx==2)nsc=n1;
if(hx==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日 08:04