QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#449250#7018. Insertion SortsycqwqWA 0ms3604kbC++14727b2024-06-20 20:39:372024-06-20 20:39:37

Judging History

你现在查看的是最新测评结果

  • [2024-06-20 20:39:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2024-06-20 20:39:37]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'