孩子们,三个小时可不好笑
查看原帖
孩子们,三个小时可不好笑
1495947
Laodamanba楼主2024/10/6 22:37
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int Bx = sc.nextInt();
        int By = sc.nextInt();
        //int test;
        long[][] matrix = new long[++Bx][++By];
        int Ma_x = sc.nextInt();
        int Ma_y = sc.nextInt();

        for (int i = 0; i < Bx; i++) {
            for (int j = 0; j < By; j++) {
                matrix[i][j] = -1;
            }
        }

        matrix[0][0] = 1;

        matrix[Ma_x][Ma_y] = 0;
        {
            if (Ma_x - 1 >= 0 && Ma_y - 2 >= 0) matrix[Ma_x - 1][Ma_y - 2] = 0;
            if (Ma_x - 2 >= 0 && Ma_y - 1 >= 0) matrix[Ma_x - 2][Ma_y - 1] = 0;
            if (Ma_x - 2 >= 0 && Ma_y + 1 <= By) matrix[Ma_x - 2][Ma_y + 1] = 0;
            if (Ma_x - 1 >= 0 && Ma_y + 2 <= By) matrix[Ma_x - 1][Ma_y + 2] = 0;
            if (Ma_x + 1 <= Bx && Ma_y - 2 >= 0) matrix[Ma_x + 1][Ma_y - 2] = 0;
            if (Ma_x + 2 <= Bx && Ma_y - 1 >= 0) matrix[Ma_x + 2][Ma_y - 1] = 0;
            if (Ma_x + 1 <= Bx && Ma_y + 2 <= By) matrix[Ma_x + 1][Ma_y + 2] = 0;
            if (Ma_x + 2 <= Bx && Ma_y + 1 <= By) matrix[Ma_x + 2][Ma_y + 1] = 0;
        }
        for (int i = 0; i < Bx; i++) {
            for (int j = 0; j < By; j++) {
                if (matrix[i][j] == -1) {
                    matrix[i][j] = 0;
                    if (i >= 1) matrix[i][j] += matrix[i-1][j];
                    if (j >= 1) matrix[i][j] += matrix[i][j-1];
                    //System.out.print(matrix[i][j] + " ");
                    //test = sc.nextInt();
                }
            }
        }

        /*for (int i = 0; i < Bx; i++) {
            for (int j = 0; j < By; j++) {
                System.out.print("\t" + matrix[i][j] + "\t");
            }
            System.out.println();
        }*/

        System.out.println(matrix[Bx-1][By-1]);
    }
}
2024/10/6 22:37
加载中...