アットウィキロゴ

pxc

class pro{
public static void main(String args[]){
int s;
double th[]=new double[101];
double c[]=new double[101];
double y[]=new double[101];
double u[][][]=new double[101][3][3];
double w[][][]=new double[101][3][3];  
double v[][][][]=new double[101][3][3][11];
int goto1[][][][]=new int[101][3][3][11];
int goto2[][][][]=new int[101][3][3][11];
int gotom[][][][]=new int[101][3][3][11];
int opc[]=new int[101];
int opy[]=new int[101];
double lam,dc,dy;
int m,n1,n2,nx1,nx2,nxs1,nxs2,mx;
double c1,y1,v1,maxv,u1,u2;
double h;
int j,e,px;
int t1,t2;

for (s=1;s<101;s++){
th[s]=0.02*s;
}

for (s=1;s<101;s++){
y[s]=0.5*th[s];
c[s]=y[s];
}

h=0.04;
t2=0;
while(t2<10){
h=h/2;
t1=0;
while(t1<1000){
for (s=1;s<101;s++){
for (n1=-1;n1<2;n1++){
for (n2=-1;n2<2;n2++){
c1=c[s]+n1*h;
y1=y[s]+n2*h;
u[s][n1+1][n2+1]=ux(c1,1-y1/th[s]);
}
}
}

for (s=1;s<100;s++){
for (n1=-1;n1<2;n1++){
for (n2=-1;n2<2;n2++){
c1=c[s]+n1*h;
y1=y[s]+n2*h;
w[s][n1+1][n2+1]=ux(c1,1-y1/th[s+1]);;
}
}
}

for (n1=-1;n1<2;n1++){
for (n2=-1;n2<2;n2++){
for (m=-5;m<6;m++){
v[1][n1+1][n2+1][m+5]=-999;
}
}
}

for (n1=-1;n1<2;n1++){
for (n2=-1;n2<2;n2++){
m=n2-n1;
v[1][n1+1][n2+1][m+5]=u[1][n1+1][n2+1];
}
}

for (s=2;s<101;s++){
for (n1=-1;n1<2;n1++){
for (n2=-1;n2<2;n2++){
for (m=-5;m<6;m++){
u1=u[s][n1+1][n2+1];
maxv=-999;
nxs1=0;
nxs2=0;
mx=m+n1-n2;
px=0;
if (mx>5)px=100;
if (mx<-5)px=100;
if (px>50)mx=0;
for (nx1=-1;nx1<2;nx1++){
for (nx2=-1;nx2<2;nx2++){
v1=u1+v[s-1][nx1+1][nx2+1][mx+5];
if (w[s-1][nx1+1][nx2+1]>u1)v1=-999;
if (v1>maxv)nxs1=nx1;
if (v1>maxv)nxs2=nx2;
if (v1>maxv)maxv=v1;
}
}
if (px>50)maxv=-999;
goto1[s][n1+1][n2+1][m+5]=nxs1;
goto2[s][n1+1][n2+1][m+5]=nxs2;
gotom[s][n1+1][n2+1][m+5]=mx;
v[s][n1+1][n2+1][m+5]=maxv;
}
}
}
}

nx1=0;
nx2=0;
maxv=-999;
for (n1=-1;n1<2;n1++){
for (n2=-1;n2<2;n2++){
if (v[100][n1+1][n2+1][5]>maxv)nx1=n1;
if (v[100][n1+1][n2+1][5]>maxv)nx2=n2;
if (v[100][n1+1][n2+1][5]>maxv)maxv=v[100][n1+1][n2+1][5];
}
}

m=0;
opc[100]=nx1;
opy[100]=nx2;
for (j=1;j<100;j++){
s=100-j;
n1=opc[s+1];
n2=opy[s+1];
opc[s]=goto1[s+1][n1+1][n2+1][m+5];
opy[s]=goto2[s+1][n1+1][n2+1][m+5];
m=gotom[s+1][n1+1][n2+1][m+5];
}
System.out.println(maxv);
for (s=1;s<101;s++){
c[s]=c[s]+opc[s]*h;
y[s]=y[s]+opy[s]*h;
}

e=0;
for (s=1;s<101;s++){
e=e+opc[s]*opc[s];
e=e+opy[s]*opy[s];
}
if (e<2)t1=1000;
System.out.println(e);
t1=t1+1;
}
t2=t2+1;
}

for (s=1;s<100;s++){
dc=c[s+1]-c[s];
dy=y[s+1]-y[s];
if (dy>0)System.out.println(1-dc/dy);
}
}
static double ux(double c1,double x1){
double u1,c2,x2;
int px;
c2=c1;
x2=x1;
px=0;
if (c2<0)px=100;
if (c2==0)px=100;
if (x2<0)px=100;
if (x2==0)px=100;
if (x2>1)px=100;
if (px>50)c2=0.5;
if (px>50)x2=0.5;
u1=Math.log(c2)+Math.log(x2);
if (px>50)u1=-999;
return u1;

}

}
最終更新:2010年07月03日 01:29