結果
| 問題 |
No.1191 数え上げを愛したい(数列編)
|
| コンテスト | |
| ユーザー |
Rho
|
| 提出日時 | 2020-07-31 22:31:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 2,000 ms |
| コード長 | 913 bytes |
| コンパイル時間 | 2,142 ms |
| コンパイル使用メモリ | 166,864 KB |
| 実行使用メモリ | 12,872 KB |
| 最終ジャッジ日時 | 2024-07-06 19:40:52 |
| 合計ジャッジ時間 | 4,728 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
const long long mod=998244353;
const long long inf=1ll<<61;
int kj[600006],kji[600006];
int modpow(int a,int x){
int res=1;
while(x){
if(x&1)res=res*a%mod;
a=a*a%mod;
x>>=1;
}
return res;
}
void setkj(){
kj[0]=kji[0]=1;
for(int i=1;i<=600002;i++){
kj[i]=kj[i-1]*i%mod;
kji[i]=modpow(kj[i],mod-2);
}
}
int comb(int r,int c){
if(r<c)return 0;
return kj[r]*kji[c]%mod*kji[r-c]%mod;
}
signed main(){
setkj();
int n,m,a,b;cin>>n>>m>>a>>b;
int ans=0;
for(int i=0;i<=b;i++){
int d=i-(n-1)*a;
if(d<0)continue;
ans+=comb(n-1+d-1,d)*(m-i)%mod;
ans%=mod;
}
cout<<ans*kj[n]%mod<<endl;
assert(2<=n&&n<=100000);
assert(2<=m&&m<=300000);
assert(1<=a&&a<=b&&b<=m-1);
}
Rho