QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#885272 | #1816. Multiple Parentheses | nullptr_qwq | AC ✓ | 280ms | 238164kb | C++17 | 2.5kb | 2025-02-06 15:03:31 | 2025-02-06 15:03:40 |
Judging History
answer
// 私は猫です
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define inf 1000000000
#define infll 1000000000000000000ll
#define pii pair<int,int>
#define rep(i,a,b,c) for(int i=(a);i<=(b);i+=(c))
#define per(i,a,b,c) for(int i=(a);i>=(b);i-=(c))
#define F(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define dF(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define cmh(sjy) while(sjy--)
#define lowbit(x) ((x)&(-(x)))
#define HH printf("\n")
#define eb emplace_back
#define poly vector<int>
#define SZ(x) ((int)x.size())
using namespace std;
void fre(){
}
template<typename T>inline void chkmax(T &x,const T &y){ x=std::max(x,y); }
template<typename T>inline void chkmin(T &x,const T &y){ x=std::min(x,y); }
const int maxn=30000005;
const int mod=998244353;
inline int qpow(int x,ll y){ int res=1; for(;y;y>>=1,x=1ll*x*x%mod)if(y&1)res=1ll*res*x%mod; return res; }
inline void inc(int &x,const int y){ x=(x+y>=mod)?(x+y-mod):(x+y); }
inline void dec(int &x,const int y){ x=(x>=y)?(x-y):(x+mod-y); }
inline void mul(int &x,const int y){ x=1ll*x*y%mod; }
inline int add(const int x,const int y){ return (x+y>=mod)?(x+y-mod):(x+y); }
inline int sub(const int x,const int y){ return (x>=y)?(x-y):(x+mod-y); }
inline int prod(const int x,const int y){ return 1ll*x*y%mod; }
#define norm Fast_mod.Fresh
#define ulll __uint128_t
struct FastMod{ull p,w;FastMod(ull p=2):p(p),w((ull)(((ulll)(1)<<64)/p)){}ull Fresh(ull x){ull d=(ull)(((ulll)(w)*x)>>64),r=x-p*d;return r>=p?r-p:r;}}Fast_mod;
namespace combi{
int fac[maxn],ifac[maxn];
void init(const int N){
fac[0]=ifac[0]=1;
F(i,1,N)fac[i]=norm(1ll*fac[i-1]*i);
ifac[N]=qpow(fac[N],mod-2);
dF(i,N-1,1)ifac[i]=norm(1ll*ifac[i+1]*(i+1));
}
inline int C(const int n,const int m){
if(m>n||n<0||m<0)return 0;
return norm(norm(1ll*fac[n]*ifac[m])*ifac[n-m]);
}
}
using namespace combi;
int n,m,k;
inline int f(int n,int m){
if(!n)return (m==0);
return sub(C((m<<1)+n-1,m),C((m<<1)+n-1,m-1));
}
void solve(){
cin>>n>>m>>k,Fast_mod=FastMod(mod),init(maxn-3); const int p=f(1,k);
int coef=1,ans=0;
F(i,0,min(m/k,n)){
if(!(i&1))inc(ans,norm(1ll*norm(1ll*C(n,i)*f(n-i,m-i*k))*coef));
else dec(ans,norm(1ll*norm(1ll*C(n,i)*f(n-i,m-i*k))*coef));
coef=norm(1ll*coef*p);
} cout<<ans;
}
signed main(){
fre(),ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int zsy=1;
F(____,1,zsy)solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 256ms
memory: 238104kb
input:
2 2 1
output:
4
result:
ok answer is '4'
Test #2:
score: 0
Accepted
time: 258ms
memory: 237932kb
input:
1 1 1
output:
0
result:
ok answer is '0'
Test #3:
score: 0
Accepted
time: 251ms
memory: 238132kb
input:
24 120 30
output:
379268651
result:
ok answer is '379268651'
Test #4:
score: 0
Accepted
time: 251ms
memory: 238124kb
input:
1451 1598 1130
output:
884873572
result:
ok answer is '884873572'
Test #5:
score: 0
Accepted
time: 261ms
memory: 238012kb
input:
1324 1742 1033
output:
856733047
result:
ok answer is '856733047'
Test #6:
score: 0
Accepted
time: 252ms
memory: 238052kb
input:
1378 1614 1335
output:
869903701
result:
ok answer is '869903701'
Test #7:
score: 0
Accepted
time: 251ms
memory: 238132kb
input:
1071 1907 1281
output:
327700529
result:
ok answer is '327700529'
Test #8:
score: 0
Accepted
time: 261ms
memory: 237932kb
input:
1204 1337 1277
output:
475981175
result:
ok answer is '475981175'
Test #9:
score: 0
Accepted
time: 255ms
memory: 237932kb
input:
146 246 100
output:
404402509
result:
ok answer is '404402509'
Test #10:
score: 0
Accepted
time: 260ms
memory: 238008kb
input:
226 183 144
output:
351921989
result:
ok answer is '351921989'
Test #11:
score: 0
Accepted
time: 253ms
memory: 237952kb
input:
234 287 158
output:
658959115
result:
ok answer is '658959115'
Test #12:
score: 0
Accepted
time: 257ms
memory: 238156kb
input:
242 156 122
output:
325586111
result:
ok answer is '325586111'
Test #13:
score: 0
Accepted
time: 245ms
memory: 238024kb
input:
168 271 135
output:
181613866
result:
ok answer is '181613866'
Test #14:
score: 0
Accepted
time: 249ms
memory: 237956kb
input:
22 25 1
output:
684860973
result:
ok answer is '684860973'
Test #15:
score: 0
Accepted
time: 280ms
memory: 238036kb
input:
45 22 15
output:
217501624
result:
ok answer is '217501624'
Test #16:
score: 0
Accepted
time: 265ms
memory: 238064kb
input:
47 29 16
output:
690840771
result:
ok answer is '690840771'
Test #17:
score: 0
Accepted
time: 268ms
memory: 237936kb
input:
2 25 25
output:
660660974
result:
ok answer is '660660974'
Test #18:
score: 0
Accepted
time: 256ms
memory: 237984kb
input:
32 34 11
output:
133387056
result:
ok answer is '133387056'
Test #19:
score: 0
Accepted
time: 255ms
memory: 238100kb
input:
88196 118335 104471
output:
7192211
result:
ok answer is '7192211'
Test #20:
score: 0
Accepted
time: 245ms
memory: 238164kb
input:
142215 57117 51272
output:
627598793
result:
ok answer is '627598793'
Test #21:
score: 0
Accepted
time: 256ms
memory: 238104kb
input:
102255 60360 51525
output:
447649003
result:
ok answer is '447649003'
Test #22:
score: 0
Accepted
time: 263ms
memory: 237944kb
input:
132449 83413 54230
output:
215816803
result:
ok answer is '215816803'
Test #23:
score: 0
Accepted
time: 254ms
memory: 238140kb
input:
68499 95762 77190
output:
393029560
result:
ok answer is '393029560'
Test #24:
score: 0
Accepted
time: 261ms
memory: 237936kb
input:
751951 751951 1
output:
804170883
result:
ok answer is '804170883'
Test #25:
score: 0
Accepted
time: 256ms
memory: 237956kb
input:
804420 1962 410
output:
869056555
result:
ok answer is '869056555'
Test #26:
score: 0
Accepted
time: 252ms
memory: 237972kb
input:
828607 63739 13
output:
926542030
result:
ok answer is '926542030'
Test #27:
score: 0
Accepted
time: 265ms
memory: 237888kb
input:
472167 20529 23
output:
142703540
result:
ok answer is '142703540'
Test #28:
score: 0
Accepted
time: 258ms
memory: 237872kb
input:
363438 363438 1
output:
764563597
result:
ok answer is '764563597'
Test #29:
score: 0
Accepted
time: 259ms
memory: 238052kb
input:
1000000 1000000 628333
output:
283487375
result:
ok answer is '283487375'
Test #30:
score: 0
Accepted
time: 247ms
memory: 238012kb
input:
1000000 1000000 900084
output:
651386967
result:
ok answer is '651386967'
Test #31:
score: 0
Accepted
time: 256ms
memory: 237948kb
input:
1000000 1000000 27328
output:
621963453
result:
ok answer is '621963453'
Test #32:
score: 0
Accepted
time: 260ms
memory: 237964kb
input:
1000000 1000000 538409
output:
997879100
result:
ok answer is '997879100'
Test #33:
score: 0
Accepted
time: 259ms
memory: 237964kb
input:
1000000 1000000 928121
output:
964724707
result:
ok answer is '964724707'
Test #34:
score: 0
Accepted
time: 255ms
memory: 237984kb
input:
685624 665877 563708
output:
257429683
result:
ok answer is '257429683'
Test #35:
score: 0
Accepted
time: 255ms
memory: 238140kb
input:
692290 942095 553970
output:
82511143
result:
ok answer is '82511143'
Test #36:
score: 0
Accepted
time: 256ms
memory: 237992kb
input:
579579 765702 631728
output:
954001361
result:
ok answer is '954001361'
Test #37:
score: 0
Accepted
time: 261ms
memory: 237900kb
input:
756854 634736 567170
output:
393747028
result:
ok answer is '393747028'
Test #38:
score: 0
Accepted
time: 253ms
memory: 238032kb
input:
649175 997874 511181
output:
242172216
result:
ok answer is '242172216'
Test #39:
score: 0
Accepted
time: 249ms
memory: 238028kb
input:
786431 1000000 999999
output:
627359027
result:
ok answer is '627359027'