Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;}
- //
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement