QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#449250 | #7018. Insertion Sort | sycqwq | WA | 0ms | 3604kb | C++14 | 727b | 2024-06-20 20:39:37 | 2024-06-20 20:39:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn=55;
int fac[maxn];
int main()
{
int _;
cin>>_;
int i=0;
while(_--)
{
++i;
int n,k,mod;
cin>>n>>k>>mod;
k=min(k,n);
fac[0]=1;
for(int i=1;i<=50;i++)
fac[i]=1ll*fac[i-1]*i%mod;
int s=0;
(s+=(1ll*fac[k]*((1ll*(n-k)*(n-k-1)%mod-(n-k)+1+mod)%mod)%mod+fac[k])%mod)%=mod;
// cout<<s<<' '<<((n-k)*(n-k-1)-(n-k))<<'\n';
(s+=1ll*k*fac[k]%mod*(n-k)%mod)%=mod;
// cout<<s<<'\n';
(s+=1ll*fac[k]*(n-k-1)%mod)%=mod;
if(k>n-1)
s=fac[n-1];
cout<<"Case #"<<i<<": "<<s<<'\n';
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3604kb
input:
4 4 1 998244353 4 2 998244353 4 3 998244353 4 4 998244353
output:
Case #1: 10 Case #2: 14 Case #3: 24 Case #4: 6
result:
wrong answer 4th lines differ - expected: 'Case #4: 24', found: 'Case #4: 6'