結果
| 問題 |
No.1186 長方形の敷き詰め
|
| コンテスト | |
| ユーザー |
auaua
|
| 提出日時 | 2020-08-22 14:05:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,447 bytes |
| コンパイル時間 | 1,570 ms |
| コンパイル使用メモリ | 167,200 KB |
| 実行使用メモリ | 27,008 KB |
| 最終ジャッジ日時 | 2024-10-15 08:22:36 |
| 合計ジャッジ時間 | 9,052 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 3 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=998244353;
const int MAX=1000010;
//Combination
long long extGCD(long long a,long long mod,long long &x,long long &y){
if(mod==0){
x=1;
y=0;
return a;
}
long long d=extGCD(mod,a%mod,y,x);
y-=(a/mod)*x;
return d;
}
long long invmod(long long a,long long mod){
long long x,y;
extGCD(a,mod,x,y);
x%=mod;
if(x<0)x+=mod;
return x;
}
ll fac[MAX],finv[MAX],inv[MAX];
void combinit(){
fac[0]=fac[1]=1;
finv[0]=finv[1]=1;
inv[1]=1;
REP(i,2,MAX){
fac[i]=fac[i-1]*i%mod;
inv[i]=invmod(i,mod);
finv[i]=finv[i-1]*inv[i]%mod;
}
}
ll comb(ll n,ll k){
if(n<k)return 0;
if(n<0||k<0)return 0;
return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
signed main(){
ll n,m;cin>>n>>m;
combinit();
ll ans=0;
rep(i,m/n+1){
ans=(ans+comb(i+m-(i*n),i))%mod;
}
if(ans<0)ans+=mod;
cout<<ans<<endl;
}
auaua