Advertisement
Guest User

244 bytes

a guest
Jun 23rd, 2015
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. int[]f(int k,int t){int q,m,i,h,f,d[]=new int[k],b[]=d.clone();for(;t-->0;){q=k;d[q*=Math.random()]++;m=0;i=q;h=1;f=0;if(d[q]>1){for(;;){if(i<0){i=k-1;h=-1;}if(d[i%k]>0){m++;d[i%k]=0;}else{if(f>0)break;h*=-1;i=q;f=1;}i+=h;}b[m-1]++;}}return b;}
  2.  
  3.  
  4. //
  5.  
  6. int[]f(int k,int t){
  7.     int q,m,i,h,f,d[]=new int[k],b[]=d.clone();
  8.     for(;t-->0;){
  9.         q=k;d[q*=Math.random()]++;
  10.         m=0;i=q;h=1;f=0;
  11.         if(d[q]>1){
  12.             for(;;){
  13.                 if(i<0){i=k-1;h=-1;}
  14.                 if(d[i%k]>0){m++;d[i%k]=0;}
  15.                 else{if(f>0)break;h*=-1;i=q;f=1;}
  16.                 i+=h;
  17.             }
  18.             b[m-1]++;
  19.         }
  20.     }
  21.     return b;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement