第 1 题:星期计算
签到
import java.util.*;
import java.math.*;
import java.io.*;
public class Main {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
public static void main(String[] args) throws Exception {
// out.println((int)(Math.pow(20, 22) % 7));
out.println(7);
out.flush();
in.close();
}
}
第 2 题:考勤刷卡
TreeSet
import java.util.*;
import java.math.*;
import java.io.*;
public class Main {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
public static void main(String[] args) throws Exception {
TreeSet<Integer> set = new TreeSet<>();
int n = Integer.parseInt(in.readLine());
for (int i = 0; i < n; i++) {
String[] s = in.readLine().split(" ");
set.add(Integer.parseInt(s[1]));
}
for (int num: set) {
out.println(num);
}
out.flush();
in.close();
}
}
第 3 题:卡片
二分
import java.util.*;
import java.math.*;
import java.io.*;
public class Main {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
static int n;
public static boolean check(int x) {
long sum = (long)(x + 1) * x / 2;
return sum >= n;
}
public static void main(String[] args) throws Exception {
n = Integer.parseInt(in.readLine());
int l = 1, r = n;
while (l < r) {
int mid = l + ((r - l) >> 1);
if (check(mid)) {
r = mid;
} else {
l = mid + 1;
}
}
out.println(l);
out.flush();
in.close();
}
}
第 4 题:最大子矩阵
明天写