第一题,企鹅号码 AC
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
for (int i = 0; i < n; i++) {
int l = in.nextInt();
char[] ch = in.next().toCharArray();
String res = "NO";
if (ch[0] == '8'&&l==11) {
res = "YES";
} else {
if (l > 11) {
int t = 0;
for (int j = 0; j < l; j++) {
if (ch[j] != '8') t++;
else break;
}
if (l - t >= 11) res = "YES";
}
}
System.out.println(res);
}
}
}
第二题,凉凉
第三题,凉凉
第四题,k次打印最小值 0.6
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = in.nextInt();
}
int min = Integer.MAX_VALUE;
for (int i = 0; i < k; i++) {
min = Integer.MAX_VALUE;
for (int j = 0; j < n; j++) {
if (arr[j] < min && arr[j] > 0) min = arr[j];
}
if (min == Integer.MAX_VALUE) min = 0;
System.out.println(min);
for (int j = 0; j < n; j++) {
arr[j] -= min;
}
}
}
}
第五题,异或运算 0.5
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] a = new int[n];
int[] b = new int[n];
for (int i = 0; i < n; i++) {
a[i]=in.nextInt();
}
for (int i = 0; i < n; i++) {
b[i]=in.nextInt();
}
int[][] c = new int[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
c[i][j] = a[i] + b[j];
}
}
int res = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if(c[i][j]==0)continue;
res = res ^ c[i][j];
}
}
System.out.println(res);
}
}
#笔试题目##腾讯#