CF1228E.Another Filling the Grid

提高+/省选-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have n×nn \times n square grid and an integer kk. Put an integer in each cell while satisfying the conditions below.

  • All numbers in the grid should be between 11 and kk inclusive.
  • Minimum number of the ii-th row is 11 (1≤i≤n1 \le i \le n).
  • Minimum number of the jj-th column is 11 (1≤j≤n1 \le j \le n).

Find the number of ways to put integers in the grid. Since the answer can be very large, find the answer modulo (109+7)(10^{9} + 7).

These are the examples of valid and invalid grid when n=k=2n=k=2.

你有一个 n×nn \times n 的方格和一个整数 kk。请在每个格子中填入一个整数,使其满足以下条件:

  • 方格中所有数字均在 11 到 kk 之间(含端点);
  • 第 ii 行的最小值为 11(1≤i≤n1 \le i \le n);
  • 第 jj 列的最小值为 11(1≤j≤n1 \le j \le n)。

求满足条件的填数方案总数。由于答案可能非常大,请对 (109+7)(10^{9} + 7) 取模。

当 n=k=2n=k=2 时,这些是合法与非法方格的示例。

输入格式

The only line contains two integers nn and kk (1≤n≤2501 \le n \le 250, 1≤k≤1091 \le k \le 10^{9}).

唯一一行包含两个整数 nn 和 kk(1≤n≤2501 \le n \le 250,1≤k≤1091 \le k \le 10^{9})。

输出格式

Print the answer modulo (109+7)(10^{9} + 7).

以 109+710^{9} + 7 为模输出答案。

输入输出样例

  • 输入#1

    2 2

    输出#1

    7
  • 输入#2

    123 456789

    输出#2

    689974806

说明/提示

In the first example, following 77 cases are possible.

In the second example, make sure you print the answer modulo (109+7)(10^{9} + 7).

在第一个例子中,共有 77 种可能的情况。

在第二个例子中,请确保输出答案对 (109+7)(10^{9} + 7) 取模的结果。

输入解题思路,AI测评打分。不知道怎么写?

首页