A8896 | Polo the Penguin and Houses
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Little penguin Polo loves his home village. The village has $n$ houses, indexed by integers from 1 to $n$ . Each house has a plaque containing an integer, the $i$ -th house has a plaque containing integer $p_{i}$ ( $1<=p_{i}<=n$ ).
Little penguin Polo loves walking around this village. The walk looks like that. First he stands by a house number $x$ . Then he goes to the house whose number is written on the plaque of house $x$ (that is, to house $p_{x}$ ), then he goes to the house whose number is written on the plaque of house $p_{x}$ (that is, to house $p_{px}$ ), and so on.
We know that:
1. When the penguin starts walking from any house indexed from 1 to $k$ , inclusive, he can walk to house number 1.
2. When the penguin starts walking from any house indexed from $k+1$ to $n$ , inclusive, he definitely cannot walk to house number 1.
3. When the penguin starts walking from house number 1, he can get back to house number 1 after some non-zero number of walks from a house to a house.
You need to find the number of ways you may write the numbers on the houses' plaques so as to fulfill the three above described conditions. Print the remainder after dividing this number by $1000000007$ $(10^{9}+7)$ .
Little penguin Polo loves walking around this village. The walk looks like that. First he stands by a house number $x$ . Then he goes to the house whose number is written on the plaque of house $x$ (that is, to house $p_{x}$ ), then he goes to the house whose number is written on the plaque of house $p_{x}$ (that is, to house $p_{px}$ ), and so on.
We know that:
1. When the penguin starts walking from any house indexed from 1 to $k$ , inclusive, he can walk to house number 1.
2. When the penguin starts walking from any house indexed from $k+1$ to $n$ , inclusive, he definitely cannot walk to house number 1.
3. When the penguin starts walking from house number 1, he can get back to house number 1 after some non-zero number of walks from a house to a house.
You need to find the number of ways you may write the numbers on the houses' plaques so as to fulfill the three above described conditions. Print the remainder after dividing this number by $1000000007$ $(10^{9}+7)$ .
输入格式
The single line contains two space-separated integers $n$ and $k$ ( $1<=n<=1000,1<=k<=min(8,n)$ ) — the number of the houses and the number $k$ from the statement.
输出格式
In a single line print a single integer — the answer to the problem modulo $1000000007$ $(10^{9}+7)$ .
输入输出样例
输入 #1
5 2
输出 #1
54
输入 #2
7 4
输出 #2
1728
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted