QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#449245 | #7018. Insertion Sort | sycqwq | WA | 0ms | 3668kb | C++14 | 648b | 2024-06-20 20:37:05 | 2024-06-20 20:37:06 |
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;
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+fac[k])%=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;
cout<<"Case #"<<i<<": "<<s<<'\n';
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3668kb
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: 24
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3600kb
input:
5000 14 37 557911987 7 10 367410643 16 14 367486993 14 13 257679469 40 1 433152019 6 1 151926713 18 10 831429839 45 23 611504891 43 41 442772417 28 29 651920513 50 43 783397267 34 9 584271757 14 40 136299073 35 24 908302831 32 29 939394321 7 19 925472381 47 24 563986517 42 37 820968349 24 8 36281506...
output:
Case #1: -489354355 Case #2: -61689600 Case #3: 27680678 Case #4: 82630678 Case #5: 1522 Case #6: 26 Case #7: 497145600 Case #8: 158517076 Case #9: 265540132 Case #10: -290663937 Case #11: 757472701 Case #12: 299738880 Case #13: -95364568 Case #14: 685128802 Case #15: 58404183 Case #16: -588043546 C...
result:
wrong answer 1st lines differ - expected: 'Case #1: 144021228', found: 'Case #1: -489354355'