Vincent的城堡

\(\mathcal{Description}\)

PB68ffb.png

\(\mathcal{Solution}\)

除去前k部分,后面的是随便怎么选的所以后面的就是\((n-k)^{n-k}\)种方案
前k部分,由于k很小,事先打个dfs算出来即可
代码

/*******************************
Author:Morning_Glory
LANG:C++
Created Time:2019年06月16日 星期日 08时10分12秒
*******************************/
#include <iostream>
#include <fstream>
#define ll long long
using namespace std;
const int mod = 1000000007;
const int xs [] = {0,1,2,9,64,625,7776,117649,2097152};
ll n,k;
ll ksm (ll a,ll b)
{
	ll s=1;
	a%=mod;
	for (;b;b>>=1,a=a*a%mod)
		if (b&1)	s=a*s%mod;
	return s;
}
int main()
{
	cin>>n>>k;
	cout<<xs[k]*ksm(n-k,n-k)%mod<<endl;
	return 0;
}

posted @ 2019-06-16 14:10  Morning_Glory  阅读(180)  评论(0编辑  收藏  举报
//