7007.Counting Bishops

Time Limit: 1s Memory Limit: 512MB

Your task is to count the number of ways $k$ bishops can be placed on an $n \times n$ chessboard so that no two bishops attack each other.

Two bishops attack each other if they are on the same diagonal.

Input Format(From the terminal/stdin)

The only input line has two integers $n$ and $k$ : the board size and the number of bishops.

  • $1 \le n \le 500$
  • $1 \le k \le n^2$

Output Format(To the terminal/stdout)

Print one integer: the number of ways modulo $10^9+7$ .

Sample Input

Copy
5 4
 · \n

Sample Output

Copy
2728
    \n
Source: CSES, Counting Problems, 2176

Submit

请先 登录

© 2025 FAQs