岗位:
秋招:一共4到笔试
ac:100 0 100 100
题目全没保存。。。。。(有空再补)
1、
import java.util.Scanner;
public class First {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m = sc.nextInt();
sc.nextLine();
for(int i = 0; i < m; i++) {
String string = sc.nextLine();
String[] split = string.split(" ");
int a = 0,b = 0;
String[] aString = split[0].split("\\.");
int count = 3;
for(int j = 0; j < aString.length; j++) {
a += Integer.parseInt(aString[j]) * Math.pow(100, count--);
}
String[] bString = split[1].split("\\.");
count = 3;
for(int j = 0; j < bString.length; j++) {
b += Integer.parseInt(bString[j]) * Math.pow(100, count--);
}
if(b > a) {
System.out.println(true);
} else {
System.out.println(false);
}
}
}
}
2、
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
public class Fourth {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int[][] array = new int[n - 1][3];
int red = 0,black = 0;
for(int i = 0; i < n - 1; i++) {
array[i][0] = sc.nextInt();
array[i][1] = sc.nextInt();
array[i][2] = sc.nextInt();
if(array[i][2] == 0) {
red++;
} else {
black++;
}
}
if(red == 0) {
System.out.println((int)((Math.pow(n, k) - n) % 1000000007));
} else if(black == 0) {
System.out.println(0);
} else {
/*int count = (int)(Math.pow(n, k) % 1000000007);
System.out.println((int)(count - Math.pow(red + 1,k) - black));*/
//红表示可以连通,黑表示不可以连通,求连通图个数和每个连通图的数量
//然后n^k减连通图元素个数^k的和再减黑色节点个数就是答案
//没时间实现类,难受。。。。。。。。。。。。。。
HashSet<ArrayList<Integer>> set = new HashSet<ArrayList<Integer>>();
}
}
}
3、
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Second {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int temp;
for(int i = 0; i < n; i++) {
temp = sc.nextInt();
if(judge(temp)) {
System.out.println(true);
} else {
System.out.println(false);
}
}
}
public static boolean judge(int number) {
Set<Integer> set = new HashSet<Integer>();
int temp,a;
while(true) {
temp = 0;
//计算各个位数的平方
String[] split = new String(number + "").split("");
for(int i = 0; i < split.length;i++) {
a = Integer.parseInt(split[i]);
temp += a * a;
}
if(temp == 1) {
return true;
}
if(set.contains(temp)) {
break;
} else {
set.add(temp);
number = temp;
}
}
return false;
}
}
4、
import java.util.Scanner;
public class Third {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String string1 = sc.nextLine();
String string2 = sc.nextLine();
String[] split1 = string1.split(" ");
String[] split2 = string2.split(" ");
int j = 0;
for(int i = 0; i < split1.length; i++) {
if((i + 1) % 4 == 0) {
System.out.print(split1[i] + " ");
if(j < split2.length) {
System.out.print(split2[j++] + " ");
}
} else {
System.out.print(split1[i] + " ");
}
}
for(; j < split2.length; j++) {
System.out.print(split2[j] + " ");
}
}
}