アットウィキロゴ

101 tax

public class tax101{
public static void main(String[] args) {
double th1[]=new double[11];
double th2[]=new double[11];
double y1[][]=new double[11][11];
double y2[][]=new double[11][11];
double c[][]=new double[11][11];
double ys1[][][]=new double[11][11][28];
double ys2[][][]=new double[11][11][28];
double cs[][][]=new double[11][11][28];
int link[][][][]=new int[11][11][28][28];
int op[][][]=new int[11][11][1001];
int opc[]=new int[28];
int op1[]=new int[28];
int op2[]=new int[28];
int x[]=new int[11];
int s1,s2,rank;
int z1,z2,z,e1;
double l1,c1,l2,u1,u2,w1,w2,h,b2;
double tk,tl,tr,maxv,maxwel,maxtk,maxtl,maxtr,we;
double t1,t2;
int m,n,n1,n2,n3,nx1,nx2,nx3,num;
for (s1=1;s1<11;s1++){
th1[s1]=0.2*s1;
}
for (s2=1;s2<11;s2++){
th2[s2]=0.1*s2;
}
maxwel=-999;
maxtk=0;
maxtl=0;
maxtr=0;
for (n1=5;n1<40;n1++){
for (n2=5;n2<40;n2++){
tk=0.01*n1;
tl=0.01*n2;
tr=trs(tk,tl,th1,th2);
we=wel(tk,tl,tr,th1,th2);;
if (we>maxwel)maxtk=tk;  
if (we>maxwel)maxtl=tl;  
if (we>maxwel)maxtr=tr;  
if (we>maxwel)maxwel=we;  
}
}
tk=maxtk;
tl=maxtl;
tr=maxtr;
for (s1=1;s1<11;s1++){
for (s2=1;s2<11;s2++){
l1=mlx(s1,s2,tk,tl,tr,th1,th2);
l2=flx(s1,s2,tk,tl,tr,th1,th2);
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
y1[s1][s2]=th1[s1]*l1;
y2[s1][s2]=th2[s2]*l2;
c[s1][s2]=w1*l1+w2*l2+tr;
}
}
n=1;
nx1=0;
nx2=0;
nx3=0;
for (n1=1;n1<4;n1++){
for (n2=1;n2<4;n2++){
for (n3=1;n3<4;n3++){
if (n1==1)nx1=0;
if (n1==2)nx1=1;
if (n1==3)nx1=-1;
if (n2==1)nx2=0;
if (n2==2)nx2=1;
if (n2==3)nx2=-1;
if (n3==1)nx3=0;
if (n3==2)nx3=1;
if (n3==3)nx3=-1;
op1[n]=nx1;
op2[n]=nx2;
opc[n]=nx3;
n=n+1;
}
}
}
h=0.001;
for (s1=1;s1<11;s1++){
for (s2=1;s2<11;s2++){
for (n=1;n<28;n++){
cs[s1][s2][n]=c[s1][s2]+opc[n]*h;
ys1[s1][s2][n]=y1[s1][s2]+op1[n]*h;
ys2[s1][s2][n]=y2[s1][s2]+op2[n]*h;
}
}
}


for (s1=1;s1<11;s1++){
for (s2=2;s2<11;s2++){
for (n1=1;n1<28;n1++){
for (n2=1;n2<28;n2++){
link[s1][s2][n1][n2]=0;
c1=cs[s1][s2][n1];
l1=ys1[s1][s2][n1]/th1[s1];
l2=ys2[s1][s2][n1]/th2[s2];
u1=ux(c1,l1,l2);
c1=cs[s1][s2-1][n2];
l1=ys1[s1][s2-1][n2]/th1[s1];
l2=ys2[s1][s2-1][n2]/th2[s2];
u2=ux(c1,l1,l2);
if (u2>u1)link[s1][s2][n1][n2]=100;
}
}
}
}


for (s1=1;s1<11;s1++){
for (s2=1;s2<11;s2++){
x[s2]=1;
}
for (num=1;num<1001;num++){
t2=0;
while(t2<100){
s2=1;
x[s2]=x[s2]+1;
t1=0;
while (t1<100){
if (x[s2]>27)s2=s2+1;
if (x[s2]<28)t1=1000;
}
rank=s2;
for (s2=1;s2<rank;s2++){
x[s2]=1;
}

z1=0;
for (s2=2;s2<11;s2++){
n1=x[s2];
n2=x[s2-1];
if(link[s1][s2][n1][n2]>50)z1=100;
}
z2=0;
e1=0;
for (s2=1;s2<11;s2++){
n=x[s2];
e1=e1-opc[n]+op1[n]+op2[n];
if(e1>1)z2=100;
if(e1<-1)z2=100;
}

z=0;
if (z1>50)z=100;
if (z2>50)z=100;
if (z<50)t2=1000;
}
for (s2=1;s2<11;s2++){
op[s1][s2][num]=x[s2];
}
}
}









}
static double bud(double tk,double tl,double tr,double th1[],double th2[]){
double b1,w1,w2,l1,l2,c1;
int s1,s2,i;
b1=0;
for (s1=1;s1<11;s1++){
for (s2=1;s2<11;s2++){
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
l1=1-(w1+w2+tr)/(3*w1);
l2=1-(w1+w2+tr)/(3*w2);
i=0;
if (l1<0)i=i+1;  
if (l2>0)i=i+1;  
if (i==2)l1=0;  
if (i==2)l2=(w2-tr)/(2*w2);  
i=0;
if (l1>0)i=i+1;  
if (l2<0)i=i+1;  
if (i==2)l1=(w1-tr)/(2*w1);  
if (i==2)l2=0;  
c1=w1*l1+w2*l2+tr;
b1=b1+th1[s1]*l1+th2[s2]*l2-c1;
}
}
return b1;
}
static double wel(double tk,double tl,double tr,double th1[],double th2[]){
double we,w1,w2,l1,l2,c1;
int s1,s2,i;
we=0;
for (s1=1;s1<11;s1++){
for (s2=1;s2<11;s2++){
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
l1=1-(w1+w2+tr)/(3*w1);
l2=1-(w1+w2+tr)/(3*w2);
i=0;
if (l1<0)i=i+1;  
if (l2>0)i=i+1;  
if (i==2)l1=0;  
if (i==2)l2=(w2-tr)/(2*w2);  
i=0;
if (l1>0)i=i+1;  
if (l2<0)i=i+1;  
if (i==2)l1=(w1-tr)/(2*w1);  
if (i==2)l2=0;  
c1=w1*l1+w2*l2+tr;
we=we+Math.log(c1)+Math.log(1-l1)+Math.log(1-l2);
}
}
return we;
}
static double trs(double tk,double tl,double[] th1,double[] th2){
double tr1,tr2,tr3,b1,b2;
int t1;
tr1=0.1;
tr2=0.05;
b1=bud(tk,tl,tr1,th1,th2);  
t1=0;
while(t1<100){
b2=bud(tk,tl,tr2,th1,th2);
tr3=tr2-b2*(tr2-tr1)/(b2-b1);
b1=b2;
tr1=tr2;
tr2=tr3;
if (b2*b2<0.001)t1=1000;  
t1=t1+1;
}
return tr2;
}
static double ux(double c1,double l1,double l2){
int pp;
double u1,cp1,lp1,lp2;
pp=0;
cp1=c1;
lp1=l1;
lp2=l2;
if (lp1<0)pp=100;  
if (lp1>0.99)pp=100;  
if (lp2<0)pp=100;  
if (lp2>0.99)pp=100;  
if (pp>50)lp1=0.5;  
if (pp>50)lp2=0.5;  
u1=Math.log(cp1)+Math.log(1-lp1)+Math.log(1-lp2);
if (pp>50)u1=-999;
return u1;
}
static double mlx(int s1,int s2,double tk,double tl,double tr,double[] th1,double th2[]){
int i;
double w1,w2,l1,l2;
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
l1=1-(w1+w2+tr)/(3*w1);
l2=1-(w1+w2+tr)/(3*w2);
i=0;
if (l1<0)i=i+1;  
if (l2>0)i=i+1;  
if (i==2)l1=0;  
if (i==2)l2=(w2-tr)/(2*w2);  
i=0;
if (l1>0)i=i+1;  
if (l2<0)i=i+1;  
if (i==2)l1=(w1-tr)/(2*w1);  
if (i==2)l2=0;  
return l1;
}
static double flx(int s1,int s2,double tk,double tl,double tr,double[] th1,double th2[]){
int i;
double w1,w2,l1,l2;
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
l1=1-(w1+w2+tr)/(3*w1);
l2=1-(w1+w2+tr)/(3*w2);
i=0;
if (l1<0)i=i+1;  
if (l2>0)i=i+1;  
if (i==2)l1=0;  
if (i==2)l2=(w2-tr)/(2*w2);  
i=0;
if (l1>0)i=i+1;  
if (l2<0)i=i+1;  
if (i==2)l1=(w1-tr)/(2*w1);  
if (i==2)l2=0;  
return l2;
}
}
最終更新:2010年05月24日 23:20