CF1228E.Another Filling the Grid
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have n×n square grid and an integer k. Put an integer in each cell while satisfying the conditions below.
- All numbers in the grid should be between 1 and k inclusive.
- Minimum number of the i-th row is 1 (1≤i≤n).
- Minimum number of the j-th column is 1 (1≤j≤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).
These are the examples of valid and invalid grid when n=k=2.
你有一个 n×n 的方格和一个整数 k。请在每个格子中填入一个整数,使其满足以下条件:
- 方格中所有数字均在 1 到 k 之间(含端点);
- 第 i 行的最小值为 1(1≤i≤n);
- 第 j 列的最小值为 1(1≤j≤n)。
求满足条件的填数方案总数。由于答案可能非常大,请对 (109+7) 取模。
当 n=k=2 时,这些是合法与非法方格的示例。
输入格式
The only line contains two integers n and k (1≤n≤250, 1≤k≤109).
唯一一行包含两个整数 n 和 k(1≤n≤250,1≤k≤109)。
输出格式
Print the answer modulo (109+7).
以 109+7 为模输出答案。
输入输出样例
输入#1
2 2
输出#1
7
输入#2
123 456789
输出#2
689974806
说明/提示
In the first example, following 7 cases are possible.

In the second example, make sure you print the answer modulo (109+7).
在第一个例子中,共有 7 种可能的情况。

在第二个例子中,请确保输出答案对 (109+7) 取模的结果。
输入解题思路,AI测评打分。不知道怎么写?