アットウィキロゴ

あうc

package p2;
 
 
public class pro {
 
    int s;
    int[] th=new int[11];
    double[] p=new double[11];
    int[] x=new int[11];
    double[][] v=new double[11][3];
    int[][] gotos=new int[11][3];
 
    public static void main(String[] args) {
       pro test=new pro();
    }
 
    pro(){
 
        for(s=1;s<11;s++){
        th[s]=10*s;
        }
 
        double p1,p2;
 
        p1=0.1;
 
        for(s=2;s<11;s++){
        p2=s*p1-0.1;
        p[s]=Math.pow(p2,9);
        }
 
 
        for(s=1;s<11;s++){
        x[s]=5*s;
        }
 
 
        int sx;
 
        s=2;
        for(sx=-1;sx<2;sx++){
        v[s][sx+1]=p[s]*(x[s]+sx);
        if(x[s]+sx>th[s])v[s][sx+1]=-999;
        } 
 
        double u1,v1,maxv,w1,w2;
        int t,z,sxs;
 
       for(t=3;t<11;t++){
       for(s=-1;s<2;s++){
       u1= p[t]*(x[t]+s);
       w1=p[t]*(th[t]-x[t]-s);
       z=0;
       if(th[t]-x[t]-s>0)z=100;
       maxv=-999;
       sxs=0;
       for(sx=-1;sx<2;sx++){
       w2=p[t-1]*(th[t]-x[t-1]-sx);
       v1=u1+v[t-1][sx+1];
       if(w2>w1)v1=-999;
       if(v1>maxv)sxs=sx;
       if(v1>maxv)maxv=v1;
       } 
       if(z>50)maxv=-999;
       v[t][s+1]=maxv;
       gotos[t][s+1]=sxs;
       }
       }
 
 
       maxv=-999;
         for(s=-1;s<2;s++){
         if(v[10][s+1]>maxv)maxv=v[10][s+1];
         }
 
       System.out.println(maxv);
 
 
 
 
 
 
    }
}
最終更新:2014年03月30日 10:41