アットウィキロゴ

vvvv99999900

package p3;
 
import tool.*;
 
 
 
public class pro {
 
int s,datanumber;
String[] data=new String[5000];    
 
 
double[] coeff=new double[50];
 
double[][] v=new double[50000][101]; 
 
    double[] lon=new double[500000];
double[] lat=new double[500000];
int[][] gotox=new int[5000][1000];
 
int[] op=new int[1001]; 
 
 
    public static void main(String[] args) {
        pro tes=new pro();
    }
 
    pro(){
 
 
        readfile sub=new readfile();
        sub.makedata("data.txt","UTF-8");
        data=sub.data;
       datanumber=sub.datanumber;
 
 
 
        for(s=1;s<datanumber+1;s++){
        String str=data[s].substring(0,2);
        int y1=Integer.parseInt(str);    
        str=data[s].substring(2,4);
        int x1=Integer.parseInt(str); 
        str=data[s].substring(4,5);
        int y2=Integer.parseInt(str);    
        str=data[s].substring(5,6);
        int x2=Integer.parseInt(str); 
        str=data[s].substring(6,7);
        int y3=Integer.parseInt(str);    
        str=data[s].substring(7,8);
        int x3=Integer.parseInt(str); 
        str=data[s].substring(8,9);
        int y4=Integer.parseInt(str);    
        str=data[s].substring(9,10);
        int x4=Integer.parseInt(str);         
        double x=80*x1+10*x2+x3+0.5*x4;
        double y=80*y1+10*y2+y3+0.5*y4;
        lon[s]=y;
        lat[s]=x;
        }
 
 
System.out.println(datanumber);
 
 int sx,n;
 
for(n=1;n<100;n++){
 v[1][n]=0;
    }
 
 
       for(s=2;s<datanumber+1;s++){
       for(n=2;n<11;n++){    
       double minv=99999; 
       int sxs=0;
       for(sx=1;sx<s;sx++){
       double v1=u(sx,s)+v[sx][n-1];    
       if(v1<minv)sxs=sx;
       if(v1<minv)minv=v1;
       }    
       gotox[s][n]=sxs;
       v[s][n]=minv;
       }   
       }
 
 
 
   op[10]=datanumber;
   for(s=1;s<10;s++){
   n=11-s;
   sx=op[n];
   op[n-1]=gotox[sx][n];
   System.out.println(n-1+","+op[n-1]);
   }
 
 
 
 
 
 
 
 
       }
 
 
 
 
 
 
   double u(int s1,int s2){
        double a1=lon[s2]-lon[s1];
        double b1=lat[s2]-lat[s1];
 
 
        int k; 
       double e=0; 
        for(k=s1+1;k<s2;k++){
        double y1=lon[k]-lon[s1];
        double x1=lat[k]-lat[s1];
        double x2=0;
       if(a1>0)x2=b1/a1*y1;
        e=e+(x2-x1)*(x2-x1);
        }
 
 
 
 
    return Math.sqrt(e);    
    }
 
 
 
 
}
 
最終更新:2015年12月01日 05:36