第一题:灭鼠先锋
// 1:无需package
// 2: 类名必须Main, 不可修改
import java.util.HashMap;
import java.util.Map;
public class Main {
public static boolean check(String s){
char[] c = s.toCharArray();
int cnt = 0;
for(int i = 0; i < c.length; i++){
if(c[i] == 'O') cnt++;
}
return cnt == 1;
}
static Map<String, Boolean> m = new HashMap<>();
public static boolean dfs(String s){
// System.out.println(s);
if(m.get(s) != null){
return m.get(s);
}
if(check(s)){
m.put(s, false);
return false;
}
for(int i = 0; i < s.length(); i++){
if(s.charAt(i) == 'O'){
char[] t = s.toCharArray();
t[i] = 'X';
if(!dfs(String.valueOf(t))){
m.put(s, true);
return true;
}
}
}
for(int i = 0; i < s.length()-1; i++){
if(i != 3 && s.charAt(i) == 'O' && s.charAt(i+1) == 'O'){
char[] t = s.toCharArray();
t[i] = t[i+1] = 'X';
if(!dfs(String.valueOf(t))){
m.put(s, true);
return true;
}
}
}
m.put(s, false);
return false;
}
public static void main(String[] args) {
String[] s = {"XOOOOOOO", "XXOOOOOO", "OXOOOOOO", "OXXOOOOO"};
for(int i = 0; i < 4; i++){
// System.out.println();
// System.out.println();
if(dfs(s[i])) {
System.out.print("L");
}else{
System.out.print("V");
}
}
}
}
第二题:小蓝与钥匙
先放着,过段时间
第三题:李白打酒加强版
import java.util.Scanner;
public class Main {
static int N = 110, MOD = 1000000007;
static long[][][] dp = new long[N+N][N][N];
public static void main(String[] args) throws Exception{
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int m = s.nextInt();
dp[0][0][2] = 1;
for(int i = 1; i <= n+m-1; i++) {
for(int j = 0; j <= n; j++) {
for(int k = 0; k <= m; k++) {
dp[i][j][k] = dp[i-1][j][k+1];
if(j != 0 && k%2 == 0) {
dp[i][j][k] = (dp[i][j][k] + dp[i-1][j-1][k/2])%MOD;
}
}
}
}
System.out.println(dp[n+m-1][n][1]);
}
}
第四题:机房
等省一后回来补题吧。。。。