class tax0910{
public static void main(String args[]){
int s1,s2;
double th1[]=new double[6];
double th2[]=new double[6];
double c[][]=new double[6][6];
double y1[][]=new double[6][6];
double y2[][]=new double[6][6];
double u[][][]=new double[6][6][3];
double w[][][]=new double[5][6][3];
double z[][][]=new double[6][5][3];
double v[][][][][][][]=new double[5][3][3][3][3][3][5];
double tk,tl,tr,tks,tls,trs;
double we,maxw;
int n,n1,n2,m;
int p1,p2,p3,p4,p5;
double cs,ys1,ys2;
double h;
for (s1=1;s1<6;s1++){
th1[s1]=0.2*s1;
}
for (s2=1;s2<6;s2++){
th2[s2]=0.1*s2;
}
maxw=-999;
tks=0;
tls=0;
trs=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>maxw)tks=tk;
if (we>maxw)tls=tl;
if (we>maxw)trs=tr;
if (we>maxw)maxw=we;
}
}
tk=tks;
tl=tls;
tr=trs;
for (s1=1;s1<6;s1++){
for (s2=1;s2<6;s2++){
y1[s1][s2]=th1[s1]*mlx(s1,s2,tk,tl,tr,th1,th2);
y2[s1][s2]=th2[s2]*flx(s1,s2,tk,tl,tr,th1,th2);
c[s1][s2]=(1-tk)*y1[s1][s2]+(1-tl)*y2[s1][s2]+tr;
}
}
h=0.005;
for (s1=1;s1<6;s1++){
for (s2=1;s2<6;s2++){
for (n=-1;n<2;n++){
cs=c[s1][s2]-n*h;
ys1=y1[s1][s2];
ys2=y2[s1][s2];
u[s1][s2][n+1]=ux(cs,1-ys1/th1[s1],1-ys2/th2[s2]);
}
}
}
for (s1=1;s1<5;s1++){
for (s2=1;s2<6;s2++){
for (n=-1;n<2;n++){
cs=c[s1][s2]-n*h;
ys1=y1[s1][s2];
ys2=y2[s1][s2];
w[s1][s2][n+1]=ux(cs,1-ys1/th1[s1+1],1-ys2/th2[s2]);
}
}
}
for (s1=1;s1<6;s1++){
for (s2=1;s2<5;s2++){
for (n=-1;n<2;n++){
cs=c[s1][s2]-n*h;
ys1=y1[s1][s2];
ys2=y2[s1][s2];
z[s1][s2][n+1]=ux(cs,1-ys1/th1[s1],1-ys2/th2[s2+1]);
}
}
}
for (p1=-1;p1<2;p1++){
for (p2=-1;p2<2;p2++){
for (p3=-1;p3<2;p3++){
for (p4=-1;p4<2;p4++){
for (p5=-1;p5<2;p5++){
for (m=-2;m<3;m++){
v[1][p1+1][p2+1][p3+1][p4+1][p5+1][m+2]=-999;
}
}
}
}
}
}
}
static double ux(double c1,double x1,double x2){
double cc1,xx1,xx2,u1;
int px;
cc1=c1;
xx1=x1;
xx2=x2;
px=0;
if (cc1<0)px=100;
if (cc1==0)px=100;
if (xx1<0)px=100;
if (xx1==0)px=100;
if (xx1>1)px=100;
if (xx2<0)px=100;
if (xx2==0)px=100;
if (xx2>1)px=100;
if (px>50)cc1=0.5;
if (px>50)xx1=0.5;
if (px>50)xx2=0.5;
u1=Math.log(cc1)+Math.log(xx1)+Math.log(xx2);
if (px>50)u1=-999;
return u1;
}
static double trs(double tk,double tl,double[] th1,double[] th2){
double tr1,tr2,tr3,b1,b2;
int t1;
tr1=0.01;
tr2=0.4;
tr3=0;
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;
b1=b2;
if (b2*b2<0.001)t1=1000;
t1=t1+1;
}
return tr3;
}
static double wel(double tk,double tl,double tr,double[] th1,double[] th2){
int s1,s2;
double ww,w1,w2,l1,l2,c1;
ww=0;
for (s1=1;s1<6;s1++){
for (s2=1;s2<6;s2++){
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
l1=mlx(s1,s2,tk,tl,tr,th1,th2);
l2=flx(s1,s2,tk,tl,tr,th1,th2);
c1=w1*l1+w2*l2+tr;
ww=ww+ux(c1,1-l1,1-l2);
}
}
return ww;
}
static double bud(double tk,double tl,double tr,double[] th1,double[] th2){
int s1,s2;
double b1,w1,w2,l1,l2,c1;
b1=0;
for (s1=1;s1<6;s1++){
for (s2=1;s2<6;s2++){
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
l1=mlx(s1,s2,tk,tl,tr,th1,th2);
l2=flx(s1,s2,tk,tl,tr,th1,th2);
c1=w1*l1+w2*l2+tr;
b1=b1+th1[s1]*l1+th2[s2]*l2-c1;
}
}
return b1;
}
static double mlx(int s1,int s2,double tk,double tl,double tr,double[] th1,double[] th2){
double uc,u1,u2,w1,w2,l1,l2,u3,u4,maxu;
double lx1,lx2,lx3,lx4,c1;
int px;
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
l1=1-(w1+w2+tr)/(3*w1);
l2=1-(w1+w2+tr)/(3*w2);
if (l1<0)l1=0;
if (l2<0)l2=0;
c1=w1*l1+w2*l2+tr;
lx1=l1;
u1=ux(c1,1-l1,1-l2);
l1=(w1-tr)/(2*w1);
if (l1<0)l1=0;
lx2=l1;
c1=w1*l1+tr;
u2=ux(c1,1-l1,1);
l2=(w2-tr)/(2*w2);
if (l2<0)l2=0;
lx3=0;
c1=w2*l2+tr;
u3=ux(c1,1-l2,1);
u4=ux(tr,1,1);
lx4=0;
maxu=-999;
l1=0;
if (u1>maxu)l1=lx1;
if (u1>maxu)maxu=u1;
if (u2>maxu)l1=lx2;
if (u2>maxu)maxu=u2;
if (u3>maxu)l1=lx3;
if (u3>maxu) maxu=u3;
if (u4>maxu)l1=lx4;
if (u4>maxu)maxu=u4;
return l1;
}
static double flx(int s1,int s2,double tk,double tl,double tr,double[] th1,double[] th2){
double uc,u1,u2,w1,w2,l1,l2,u3,u4,maxu;
double lx1,lx2,lx3,lx4,c1;
int px;
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
l1=1-(w1+w2+tr)/(3*w1);
l2=1-(w1+w2+tr)/(3*w2);
if (l1<0)l1=0;
if (l2<0)l2=0;
c1=w1*l1+w2*l2+tr;
lx1=l2;
u1=ux(c1,1-l1,1-l2);
l1=(w1-tr)/(2*w1);
if (l1<0)l1=0;
lx2=0;
c1=w1*l1+tr;
u2=ux(c1,1-l1,1);
l2=(w2-tr)/(2*w2);
if (l2<0)l2=0;
lx3=l2;
c1=w2*l2+tr;
u3=ux(c1,1-l2,1);
u4=ux(tr,1,1);
lx4=0;
maxu=-999;
l2=0;
if (u1>maxu)l2=lx1;
if (u1>maxu) maxu=u1;
if (u2>maxu) l2=lx2;
if (u2>maxu) maxu=u2;
if (u3>maxu) l2=lx3;
if (u3>maxu) maxu=u3;
if (u4>maxu) l2=lx4;
if (u4>maxu) maxu=u4;
return l2;
}
}
最終更新:2010年09月11日 19:57