結果

問題 No.3394 Big Binom
コンテスト
ユーザー Mike scarf
提出日時 2025-12-12 15:16:26
言語 C++23
(gcc 13.3.0 + boost 1.89.0)
結果
TLE  
実行時間 -
コード長 715 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,716 ms
コンパイル使用メモリ 275,764 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-12 15:16:42
合計ジャッジ時間 15,076 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19 TLE * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |     scanf("%lld %lld",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=200000;
const ll mod=998244353;
ll qmksm(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
ll ny(ll n){
    return qmksm(n,mod-2);
}
int main(){
    ll n,k,i,j,ans,zc,zc1,cur1,cur2;
    scanf("%lld %lld",&n,&k);
    if(k<0 or k>n){
        printf("0\n");
        return 0;
    }
    if(k==0 or k==n){
        printf("1\n");
        return 0;
    }
    if(k>n/2)
        k=n-k;
    cur1=1,cur2=1;
    for(i=1;i<=k;i++){
        cur1=cur1*((n-i+1)%mod)%mod;
        cur2=cur2*i%mod;
    }
    ans=cur1*ny(cur2)%mod;
    printf("%lld\n",ans);
    return 0;
}
0