# 腾讯模拟题题解

3
0 0 2 2
0 2 0 2
0 1 5 6
1 6 0 5
0 0 7 7
0 3 0 3

Yes

Yes

No

```public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
final int t = Integer.valueOf(sc.nextLine());
List ret  = new ArrayList();
int index = 0;
while (index++ < t){
String rowx = sc.nextLine();
String rowy = sc.nextLine();
String[] row_x = rowx.split(" ");
String[] row_y = rowy.split(" ");
int[] x = new int[4];
int[] y = new int[4];
for(int i = 0; i < row_x.length; i++){
x[i] = Integer.valueOf(row_x[i]);
y[i] = Integer.valueOf(row_y[i]);
}
if(solve(x, y)){
}else {
}
}
for(int i = 0; i < ret.size(); i++){
System.out.println(ret.get(i));
}
}
public static boolean solve(int[] x, int[] y){
double[] dd = new double[6];
int index = 0;
for(int i = 0; i < 3; i++){
for(int j = i + 1; j < 4; j++){
dd[index++] = dis(x, y, i, j);
}
}
Map<Double, Integer> map = new HashMap<>();
for(int i = 0; i < dd.length; i++){
map.put(dd[i], map.getOrDefault(dd[i], 0) + 1);
}
if(map.size() != 2) return false;

int iter = 0;
int first = 0;
int second = 0;
for(Map.Entry<Double, Integer> entry : map.entrySet()){
if(iter == 0) first = entry.getValue();
else if(iter == 1) second = entry.getValue();
iter++;
}

if((first == 2 && second == 4) || (first == 4 && second == 2))
return true;
return false;
}

public static double dis(int[] x, int[] y, int a, int b){
return Math.sqrt((double)(x[a] - x[b]) * (x[a] - x[b]) + (y[a] - y[b]) * (y[a] - y[b]));
}```

1, 1, 2, 2, 4, 4, 8, 8, ...(无穷尽也)

10 -> 1010 -> 统计连续0的结果是{1,1}
13 -> 1101 -> 统计连续0的结果是{0,1}
14 -> 1110 -> 统计连续0的结果是{0,0,1} 有两个0是因为高三位每两个一之间都没有0

```public static void main(String[] args) {
Scanner in = new Scanner(System.in);
final long n = Long.valueOf(in.nextLine());
final char[] nn = Long.toBinaryString(n).toCharArray();
int sum = 1;
int ret = 1;
List<Integer> zeros = countZeros(nn);
for(int i = 0; i < zeros.size(); i++){
ret += zeros.get(i) * sum;
sum += ret;
}
System.out.println(ret);
}
public static List<Integer> countZeros(char[] x){
int consecutive = 0;
List<Integer> ret = new ArrayList<>();
int n = x.length - 1;
if(x[n] == '1')
n = n - 1;
while (n >= 0){
if(x[n] == '0'){
consecutive++;
}else {
consecutive = 0;
}
n--;
}
return ret;
}```

# 近期热帖

• 回复(10) 发表于 2019-03-19 22:40:55
• 回复(6) 发表于 今天 10:56:56
• 回复(14) 发表于 2019-03-19 19:19:57
• 回复(4) 发表于 2019-03-19 23:30:24
• 回复(7) 发表于 今天 00:32:33
• 回复(7) 发表于 今天 00:16:07
• 回复(0) 发表于 今天 07:52:16
• 回复(7) 发表于 2019-03-19 22:07:42
• 回复(2) 发表于 今天 11:50:36
• 回复(4) 发表于 2019-03-19 22:00:20

# 热门推荐

• 扫描二维码，关注牛客网

• 下载牛客APP，随时随地刷题

• 公司地址：北京市朝阳区大屯路东金泉时代3-2708北京牛客科技有限公司