QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#737233#7018. Insertion Sortwaylonguo#WA 8ms3580kbC++141.1kb2024-11-12 15:09:152024-11-12 15:09:16

Judging History

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

  • [2024-11-12 15:09:16]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3580kb
  • [2024-11-12 15:09:15]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using namespace __gnu_pbds;
using ordered_multiset=tree<int,null_type,less_equal<int>,
rb_tree_tag,tree_order_statistics_node_update>;
typedef long long ll;
ll frac(ll n,ll q){
    ll res=1;
    for(int i=1;i<=n;i++){
        res=res*i;
        res=res%q;
    }
    return res;
}
void solve(){
    ll n,k,q;
    cin>>n>>k>>q;
    ll ans=0,res=0;
    if(k==1){
        ans=1,res=1;
        for(int i=2;i<=n;i++){
            ans=ans+res;
            ans=ans%q;
            res=res+2;
            res=res%q;
        }
        cout<<ans;
        return;
    }
    ll frc=frac(k,q);
    ans=frc;
    res=frc*k;
    res=res%q;
    for(int i=k+1;i<=n;i++){
        ans=ans+res;
        ans=ans%q;
        res=res+2*frc;
        res=res%q;
    }
    cout<<ans;
    return;
}
int main(){
    int T;
    cin>>T;
    for(int _=1;_<=T;_++){
        cout<<"Case #"<<_<<": ";
        solve();
        cout<<endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

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: 8ms
memory: 3576kb

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: 374207516
Case #2: 3628800
Case #3: 27680678
Case #4: 82630678
Case #5: 1522
Case #6: 26
Case #7: 497145600
Case #8: 158517076
Case #9: 265540132
Case #10: 487582834
Case #11: 757472701
Case #12: 299738880
Case #13: 43963396
Case #14: 685128802
Case #15: 58404183
Case #16: 34351948
Case #17...

result:

wrong answer 1st lines differ - expected: 'Case #1: 144021228', found: 'Case #1: 374207516'