QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#620357#8149. Station of Fatecy325WA 0ms3576kbC++20916b2024-10-07 17:42:102024-10-07 17:42:12

Judging History

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

  • [2024-10-07 17:42:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3576kb
  • [2024-10-07 17:42:10]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=998244353;
ll an[100005];
ll mul(ll a,ll b,ll mod){
    a=a%mod;
    b=b%mod;
    ll res=0;
    while(b>0){
        if(b&1)res=(res+a)%mod;
        a=(a+a)%mod;
        b>>=1;
    }
    return res;
}
ll A(ll a){
    ll ans=1;
    for(ll i=1;i<=a;i++) {
        ans=mul(ans,i,mod);
    }
    return ans%mod;
}
ll C(ll cn,ll cm){
    ll ans_cm=A(cm);
    ll ans_cn=1;
    cm=min(cm,cn-cm);
    for(ll i=cn;cm>0;cm--,cn--){
        ans_cn=mul(ans_cn,i,mod);
    }
    return ans_cn/ans_cm;
}

signed main() {
    ios::sync_with_stdio(false),cin.tie(nullptr);
    ll n,m;
    cin>>n>>m;
//    ll a=0x7877665544332211;
//    ll b=0x7988776655443322;
//    ll mod=0x998776655443322;
//    cout<<mul(a,b,mod);
//    cout<<(C(n-1,m-1)%mod)<<endl;
    cout<<((C(n-1,m-1)%mod)*(A(n)%mod))%mod<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3576kb

input:

2
3 2
6 3

output:

0

result:

wrong answer 1st lines differ - expected: '12', found: '0'