(int v)
| 120 | // 随机生成arr[1...n]确保没有重复数值 |
| 121 | // 为了测试 |
| 122 | public static void random(int v) { |
| 123 | HashSet<Integer> set = new HashSet<>(); |
| 124 | for (int i = 1, cur; i <= n; i++) { |
| 125 | do { |
| 126 | cur = (int) (Math.random() * v * 2) - v; |
| 127 | } while (set.contains(cur)); |
| 128 | set.add(cur); |
| 129 | arr[i] = cur; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | // 如下四个数组用来做备份 |
| 134 | public static int[] a = new int[MAXN]; |
no test coverage detected