题解 | #明明的随机数#
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
看到500 直接桶排序,且不要 500 长度的数组
import java.io.BufferedReader;
import java.io.IOException;import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n = Integer.valueOf(br.readLine());
int [] arr = new int [16];
while(n-->0){
int num = Integer.valueOf(br.readLine());
int a = num/16;
int b = num&(15);
arr[b]|=(1<<a);
}
int x = -1;
while(++x<32){
for(int i = 0;i<16;i++){
if((arr[i]&(1<<x))!=0){
arr[i]-=(1<<x);
System.out.println((x<<4)+i);
}
}
}
}
}