アットウィキロゴ

eansuu

package math;
 
import org.apache.commons.math3.random.RandomDataGenerator;
 
public class pro {
 
    int n;
int[] x=new int[11];
int[][] y=new int[1001][11];
int[] z=new int[1001];
int[][] count=new int[11][21];
int[][] value=new int[11][21];
int[][] plus=new int[11][21];
int[][] rank=new int[11][21];
double[][] p=new double[11][21];
int s,sx,v1,t;
    public static void main(String[] args) {
        pro test=new pro();
    }
pro(){
RandomDataGenerator rand=new RandomDataGenerator();
 
 
for(t=1;t<1001;t++){
 
for(s=1;s<11;s++){
n = rand.nextInt(1, 20);
x[s]=n;
}
 
for(s=1;s<11;s++){
y[t][s]=x[s];
}
 
v1=v();
z[t]=v1;
}
 
 
 
for(t=1;t<1001;t++){
for(s=1;s<11;s++){
sx=y[t][s];
count[s][sx]=count[s][sx]+1;
value[s][sx]=value[s][sx]+z[t];
}
}
 
  for(s=1;s<11;s++){  
    for(sx=1;sx<21;sx++){
    if(count[s][sx]>0)plus[s][sx]=value[s][sx]/count[s][sx];    
    }
    }
 
for(s=1;s<11;s++){ 
ranking(s);    
}
 
sx=20;
for(s=1;s<11;s++){ 
System.out.println(rank[s][sx]);    
}
 
}
 
void ranking(int tr){
int s,sx,r;
int[] ch=new int[30];
int maxp,h;
 
for(r=1;r<21;r++){
maxp=0;
sx=0;
for(s=1;s<21;s++){
h=0;
if(plus[tr][s]>maxp)h=h+1;
if(ch[s]<60)h=h+1;
if(h==2)maxp=plus[tr][s];
if(h==2)sx=s;
}
rank[tr][r]=sx;
ch[sx]=100;
}
 
 
 
}
 
int v(){
int s,v1,v2;
v1=0;
v2=0;
for(s=1;s<11;s++){
v1=v1+x[s]*x[s];    
v2=v2+x[s];
}    
v2=100-v2;
v1=v1+10*v2*v2;
return v1;
}
 
 
}
最終更新:2015年11月11日 17:12