class
pro{
public static void main(String args[]){
double tl,tr,h;
int s,n1,n2,n3,n4,n5,n6;
double th[]=
new double
[101];
double c[]=new double[101];
double y[]=new double[101];
double ux[][][][][][][]=new double[101][3][3][3][3][3][3];
double bx[][][][][][][]=new double[101][3][3][3][3][3][3];
double fastu[][][][]=new double[3][3][3][3];
double endu[][][][]=new double[3][3][3][3];
double fastb[][][][]=new double[3][3][3][3];
double endb[][][][]=new double[3][3][3][3];
h=0.01;
for (s=1;s<101;s++){
th[s]=0.02*s;
}
tl=tls(th);
tr=trs(th,tl);
for (s=1;s<101;s++){
y[s]=th[s]*lx(th[s],tl,tr);
c[s]=(1-tl)*y[s]+tr;
}
for (s=2;s<
100;s++){
for (n1=0;n1<3;n1++){
for (n2=0;n2<3;n2++){
for (n3=0;n3<3;n3++){
for (n4=0;n4<3;n4++){
for (n5=0;n5<3;n5++){
for (n6=0;n6<3;n6++){
ux[s][n1][n2][n3][n4][n5][n6]=seeku(s,n1,n2,n3,n4,n5,n6,c,y,th,h);
}
}
}
}
}
}
}
for (n1=0;n1<3;n1++){
for (n2=0;n2<3;n2++){
for (n3=0;n3<3;n3++){
for (n4=0;n4<3;n4++){
fastu[n1][n2][n3][n4]=seekfastu(n1,n2,n3,n4,c,y,th,h);
}
}
}
}
for (n1=0;n1<3;n1++){
for (n2=0;n2<3;n2++){
for (n3=0;n3<3;n3++){
for (n4=0;n4<3;n4++){
endu[n1][n2][n3][n4]=seekendu(n1,n2,n3,n4,c,y,th,h);
}
}
}
}
for (s=2;s<100;s++){
for (n1=0;n1<3;n1++){
for (n2=0;n2<3;n2++){
for (n3=0;n3<3;n3++){
for (n4=0;n4<3;n4++){
for (n5=0;n5<3;n5++){
for (n6=0;n6<3;n6++){
bx[s][n1][n2][n3][n4][n5][n6]=seekb(s,n1,n2,n3,n4,n5,n6,c,y,th,h);
}
}
}
}
}
}
}
for (n1=0;n1<3;n1++){
for (n2=0;n2<3;n2++){
for (n3=0;n3<3;n3++){
for (n4=0;n4<3;n4++){
fastb[n1][n2][n3][n4]=seekfastb(n1,n2,n3,n4,c,y,th,h);
}
}
}
}
for (n1=0;n1<3;n1++){
for (n2=0;n2<3;n2++){
for (n3=0;n3<3;n3++){
for (n4=0;n4<3;n4++){
endb[n1][n2][n3][n4]=seekendb(n1,n2,n3,n4,c,y,th,h);
}
}
}
}
}
public static double seekfastu(int n1,int n2,int n3,int n4,double[] c,double[] y,double[] th,double h){
double c1,c2,c3,y1,y2,y3,u1,u2,u3,maxu;
c1=c[2]+(n1-1)*h;
y1=y[2]+(n2-1)*h;
c2=c[1]+(n3-1)*h;
y2=y[1]+(n4-1)*h;
u1=u(c1,y1/th[1]);
u2=u(c2,y2/th[2]);
maxu=-
999;
if (u1>maxu)maxu=u1;
if (u2>maxu)maxu=u2;
return maxu;
}
public static double seekendu(int n1,int n2,int n3,int n4,double[] c,double[] y,double[] th,double h){
double c1,c2,c3,y1,y2,y3,u1,u2,u3,maxu;
c1=c[100]+(n1-1)*h;
y1=y[100]+(n2-1)*h;
c2=c[99]+(n3-1)*h;
y2=y[99]+(n4-1)*h;
u1=u(c1,y1/th[1]);
u2=u(c2,y2/th[2]);
maxu=-999;
if (u1>maxu)maxu=u1;
if (u2>maxu)maxu=u2;
return maxu;
}
public static double seeku(int s,int n1,int n2,int n3,int n4,int n5,int n6,double[] c,double[] y,double[] th,double h){
double c1,c2,c3,y1,y2,y3,u1,u2,u3,maxu;
c1=c[s+1]+(n1-1)*h;
y1=y[s+1]+(n2-1)*h;
c2=c[s]+(n3-1)*h;
y2=y[s]+(n4-1)*h;
c3=c[s-1]+(n5-1)*h;
y3=y[s-1]+(n6-1)*h;
u1=u(c1,y1/th[s]);
u2=u(c2,y2/th[s]);
u3=u(c3,y3/th[s]);
maxu=-999;
if (u1>maxu)maxu=u1;
if (u2>maxu)maxu=u2;
if (u3>maxu)maxu=u3;
return maxu;
}
public static double seekb(int s,int n1,int n2,int n3,int n4,int n5,int n6,double[] c,double[] y,double[] th,double h){
double c1,c2,c3,y1,y2,y3,u1,u2,u3,maxu,bx;
int j,z;
c1=c[s+1]+(n1-1)*h;
y1=y[s+1]+(n2-1)*h;
c2=c[s]+(n3-1)*h;
y2=y[s]+(n4-1)*h;
c3=c[s-1]+(n5-1)*h;
y3=y[s-1]+(n6-1)*h;
u1=u(c1,y1/th[s]);
u2=u(c2,y2/th[s]);
u3=u(c3,y3/th[s]);
maxu=-999;
j=1;
if (u1>maxu)j=1;
if (u1>maxu)maxu=u1;
if (u2>maxu)j=2;
if (u2>maxu)maxu=u2;
if (u3>maxu)j=3;
if (u3>maxu)maxu=u3;
bx=0;
if(j==1)bx=y1-c1;
if(j==2)bx=y2-c2;
if(j==3)bx=y3-c3;
bx=bx-(y[s]-c[s]);
z=(int)(bx/h);
return z;
}
public static double seekfastb(int n1,int n2,int n3,int n4,double[] c,double[] y,double[] th,double h){
double c1,c2,c3,y1,y2,y3,u1,u2,u3,maxu,bx;
int j,z;
c1=c[2]+(n1-1)*h;
y1=y[2]+(n2-1)*h;
c2=c[1]+(n3-1)*h;
y2=y[1]+(n4-1)*h;
u1=u(c1,y1/th[1]);
u2=u(c2,y2/th[1]);
maxu=-999;
j=1;
if (u1>maxu)j=1;
if (u1>maxu)maxu=u1;
if (u2>maxu)j=2;
if (u2>maxu)maxu=u2;
bx=0;
if(j==1)bx=y1-c1;
if(j==2)bx=y2-c2;
bx=bx-(y[1]-c[1]);
z=(int)(bx/h);
return z;
}
public static double seekendb(int n1,int n2,int n3,int n4,double[] c,double[] y,double[] th,double h){
double c1,c2,c3,y1,y2,y3,u1,u2,u3,maxu,bx;
int j,z;
c1=c[100]+(n1-1)*h;
y1=y[100]+(n2-1)*h;
c2=c[99]+(n3-1)*h;
y2=y[99]+(n4-1)*h;
u1=u(c1,y1/th[100]);
u2=u(c2,y2/th[100]);
maxu=-999;
j=1;
if (u1>maxu)j=1;
if (u1>maxu)maxu=u1;
if (u2>maxu)j=2;
if (u2>maxu)maxu=u2;
bx=0;
if(j==1)bx=y1-c1;
if(j==2)bx=y2-c2;
bx=bx-(y[100]-c[100]);
z=(int)(bx/h);
return z;
}
public static double tls(double[] th){
double tl,tr,w1,maxwel,maxtl;
int n;
maxtl=0;
maxwel=-999;
for (n=10;n<50;n++){
tl=0.01*n;
tr=trs(th,tl);
w1=wel(th,tl,tr);
if (w1>maxwel)maxtl=tl;
if (w1>maxwel)maxwel=w1;
}
return maxtl;
}
public static double trs(double[] th,double tl){
double tr1,tr2,tr3,b1,b2;
int t1;
tr1=0.1;
tr2=0.2;
b1=bud(th,tl,tr1);
t1=0;
while(t1<100){
b2=bud(th,tl,tr2);
tr3=tr2-b2*(tr2-tr1)/(b2-b1);
b1=b2;
tr1=tr2;
tr2=tr3;
t1=t1+1;
if (b2*b2<0.001)t1=1000;
}
return tr2;
}
public static double wel(double[] th,double tl,double tr){
double c1,l1,w1;
int n;
w1=0;
for (n=1;n<101;n++){
c1=cx(th[n],tl,tr);
l1=lx(th[n],tl,tr);
w1=w1+u(c1,1-l1);
}
return w1;
}
public static double bud(double[] th,double tl,double tr){
double c1,y1,b1;
int n;
b1=0;
for (n=1;n<101;n++){
c1=cx(th[n],tl,tr);
y1=th[n]*lx(th[n],tl,tr);
b1=b1+y1-c1;
}
return b1;
}
public static double cx(double th1,double tl,double tr){
double l1,w1,c1;
l1=lx(th1,tl,tr);
w1=(1-tl)*th1;
c1=w1*l1+tr;
return c1;
}
public static double lx(double th1,double tl,double tr){
double w1,l1;
w1=(1-tl)*th1;
l1=(w1-tr)/(2*w1);
if (l1<0)l1=0;
return l1;
}
public static double u(double c1,double x1){
double c2,x2,z2,u2;
c2=c1;
x2=x1;
z2=0;
if (c2<0.001)z2=100;
if (x2>1)z2=100;
if (x2<0)z2=100;
if (z2>50)c2=0.01;
if (z2>50)x2=0.5;
u2=Math.log(c2)+Math.log(x2);
if (z2>50)u2=-999;
return u2;
}
}
最終更新:2010年04月13日 04:33