結果

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

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn=200005;
const ll mod=998244353;
ll s[maxn+5],p[maxn+5];
ll ksm(ll a,ll b){
    ll ans,i,j,k;
    ans=1;
    while(b){
        if(b&1)
            ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
ll cal(ll n,ll m){
    ll zc,zc1,i,j,k;
    if(m<0 or m>n)
        return 0;
    if(m==0 or m==n)
        return 1;
    if(m>n/2)
        m=n-m;
    zc=1,zc1=1;
    for(i=1;i<=m;i++){
        zc=zc*(n-i+1)%mod;
        zc1=zc1*i%mod;
    }
    return zc*ksm(zc1,mod-2)%mod;
}
ll luc(ll n,ll m){
    ll i,j,k;
    if(m==0)
        return 1;
    return luc(n/mod,m/mod)*cal(n%mod,m%mod)%mod;
}
int main(){
    ll n,m,t,ans,i,j,k;
    scanf("%lld%lld",&n,&m);
    ans=luc(n,m);
    printf("%lld\n",ans);
    return 0;
}
0