QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#196217 | #6956. Many Topological Problems | yiyiyi# | AC ✓ | 49ms | 3636kb | C++14 | 687b | 2023-10-01 14:12:44 | 2023-10-01 14:12:44 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define inf 0x3f3f3f3f
#define re register
#define N 1020030
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int mo=1000000007;
inline int read(){
int x=0,w=0;char ch=getchar();
while (!isdigit(ch))w|=ch=='-',ch=getchar();
while (isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
return w?-x:x;
}
void solve(){
int n=read(),k=read(),ans=1;
if (n==k)--k;
for (int i=1;i<=k;++i)ans=ans*i%mo;
for (int i=1;i<=n;++i)ans=ans*i%mo;
for (int i=1;i<=n-k-1;++i)ans=ans*k%mo;
cout<<ans<<endl;
}
signed main(){
int T=read();
while (T--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 49ms
memory: 3636kb
input:
10 1 1 700503 623646 939811 584922 752155 569391 348265 116258 839298 839298 800391 216447 150847 116426 370812 168588 1000000 407619
output:
1 972550684 617838838 561525568 470024873 910196299 782371500 133886363 868118624 262962652
result:
ok 10 lines