题目搜集于各位前辈,侵删。
第一题
//签到题
import java.util.Scanner;
public class i1901 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int t = 0;t<T;t++) {
int min = Integer.MAX_VALUE;
for(int i = 0;i<4;i++) {
min = Math.min(min, sc.nextInt());
}
System.out.println(min);
}
sc.close();
}
}
第二题
//闰年判断,easy
import java.util.Scanner;
public class i1902 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int t = 0;t<T;t++) {
int x = sc.nextInt();
int y = sc.nextInt();
int count = 0;
for(int i = x;i<=y;i++) {
if((i%4==0&&i%100!=0)||i%400==0) {
count++;
}
}
System.out.println(count);
}
sc.close();
}
}
第三题
//找好下标,每次输出一下链表看一下即可
import java.util.Scanner;
public class i1903 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int t=0;t<T;t++) {
int n = sc.nextInt();
int m = sc.nextInt();
int[] arr = new int[n+1];
for(int i = 1;i<=n;i++) {
arr[i] = i;
}
for(int i = 0;i<m;i++) {
int op = sc.nextInt();
if(op == 1) {
int x = sc.nextInt();
int flag = 0;//是否遇到x
for(int j = 1;j<=n-1;j++) {
if(arr[j] == x) {
flag = 1;
}
if(flag == 1) {
arr[j] = arr[j+1];
}
}
n--;
}else if(op == 2) {
for(int j = 1;j<=n/2;j++) {
int temp = arr[j];
arr[j] = arr[n-j+1];
arr[n-j+1] = temp;
}
}else {//op = 3
int x = sc.nextInt();
int ans = -1;
for(int j = 1;j<=n-1;j++) {
if(arr[j] == x) {
ans = arr[j+1];
break;
}
}
if(ans == -1) {
System.out.println("NONE");
}else {
System.out.println(ans);
}
}
// System.out.print("现在的序列:");
// for(int j = 1;j<=n;j++) {
// System.out.print(arr[j]+" ");
// }
// System.out.println();
}
}
sc.close();
}
}
第四题
没找到原题
听说是最小生成树,把边排序让后并查集控制环即可,其他年份应该会有类似