結果

問題 No.1191 数え上げを愛したい(数列編)
ユーザー kotatsugamekotatsugame
提出日時 2020-10-08 04:06:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 64,872 KB
実行使用メモリ 11,660 KB
最終ジャッジ日時 2023-09-27 11:36:07
合計ジャッジ時間 1,685 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
11,496 KB
testcase_01 AC 10 ms
11,508 KB
testcase_02 AC 9 ms
11,440 KB
testcase_03 AC 9 ms
11,516 KB
testcase_04 AC 9 ms
11,580 KB
testcase_05 AC 9 ms
11,440 KB
testcase_06 AC 10 ms
11,468 KB
testcase_07 AC 10 ms
11,576 KB
testcase_08 AC 10 ms
11,576 KB
testcase_09 AC 10 ms
11,512 KB
testcase_10 AC 10 ms
11,444 KB
testcase_11 AC 9 ms
11,576 KB
testcase_12 AC 9 ms
11,580 KB
testcase_13 AC 9 ms
11,560 KB
testcase_14 AC 10 ms
11,520 KB
testcase_15 AC 9 ms
11,580 KB
testcase_16 AC 8 ms
11,572 KB
testcase_17 AC 9 ms
11,580 KB
testcase_18 AC 9 ms
11,444 KB
testcase_19 AC 8 ms
11,432 KB
testcase_20 AC 9 ms
11,432 KB
testcase_21 AC 9 ms
11,576 KB
testcase_22 AC 9 ms
11,660 KB
testcase_23 AC 9 ms
11,636 KB
testcase_24 AC 9 ms
11,492 KB
testcase_25 AC 9 ms
11,576 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#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-2+i,N-2)*(M-i-(N-1)*A))%=mod;
	}
	for(int i=1;i<=N;i++)ans=ans*i%mod;
	cout<<ans<<endl;
}
0