繁华模拟赛 Vincent的城堡-LMLPHP

繁华模拟赛 Vincent的城堡-LMLPHP

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const ll mod = ;
ll n,k,c[][];
ll ansa,ansb,ans;
void get_c(){
for(int i = ;i <= ;i++){
c[i][] = c[i][i] = ;
c[i][] = c[i][i-] = i;
}
for(int i = ;i <= ;i++){
for(int j = ;j < i;j++){
c[i][j] = c[i-][j-] + c[i-][j];
}
}
}
ll q_mul(ll a,ll b){
ll ans = ;
while(b){
if(b&){
ans = (ans + a) % mod;
}
a = (a + a) % mod;
b >>= ;
}
return ans;
}
ll q_pow(ll a,ll b){
ll ans = ;
while(b){
if(b&){
ans = q_mul(ans,a);
}
a = q_mul(a,a);
b >>= ;
}
return ans;
}
int main(){
freopen("castle.in","r",stdin);
freopen("castle.out","w",stdout);
cin>>n>>k;
get_c();
ansb = q_pow(n-k,n-k);
ansa = q_pow(k,k-);//诡异结论
ans = q_mul(ansa,ansb);
cout<<ans;
return ;
}
05-08 08:43