結果
| 問題 | 
                            No.1191 数え上げを愛したい(数列編)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-10-08 04:04:57 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 644 bytes | 
| コンパイル時間 | 591 ms | 
| コンパイル使用メモリ | 66,532 KB | 
| 実行使用メモリ | 11,816 KB | 
| 最終ジャッジ日時 | 2024-07-20 05:41:24 | 
| 合計ジャッジ時間 | 1,876 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 11 WA * 15 | 
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~
            
            ソースコード
#include<iostream>
using namespace std;
const long mod=998244353;
int N,M,A,B;
long fac[4<<17],inv[4<<17];
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long comb(int a,int b){return fac[a]*inv[b]%mod*inv[a-b]%mod;}
main()
{
	cin>>N>>M>>A>>B;
	fac[0]=1;
	for(int i=1;i<4<<17;i++)fac[i]=fac[i-1]*i%mod;
	inv[(4<<17)-1]=power(fac[(4<<17)-1],mod-2);
	for(int i=(4<<17)-1;i--;)inv[i]=inv[i+1]*(i+1)%mod;
	if((long)(N-1)*A>B)
	{
		cout<<0<<endl;
		return 0;
	}
	int T=B-(N-1)*A;
	long ans=0;
	for(int i=0;i<=T;i++)
	{
		(ans+=comb(N-1+i,N-1)*(M-i-(N-1)*A))%=mod;
	}
	for(int i=1;i<=N;i++)ans=ans*i%mod;
	cout<<ans<<endl;
}