QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#49101#1816. Multiple ParenthesesCrysflyAC ✓132ms88024kbC++112.4kb2022-09-19 14:55:542022-09-19 14:55:54

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-19 14:55:54]
  • 评测
  • 测评结果:AC
  • 用时:132ms
  • 内存:88024kb
  • [2022-09-19 14:55:54]
  • 提交

answer

// what is matter? never mind. 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define int long long 
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}

// modint
#define mod 998244353
struct modint{
	int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,int b){return a.x==b;}
	friend bool operator !=(modint a,int b){return a.x!=b;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 500005
#define inf 0x3f3f3f3f3f3f3f3f

modint F(int i,int j){
	if(!j)return 1;
	return C(i-1+2*j,j)-C(i-1+2*j,j-1);
}

signed main()
{
	int n=read(),m=read(),k=read();
	modint res=0;
	modint now=1,fk=F(1,k);
	For(i,0,min(n,m/k))
		res+=sign(i)*F(n-i,m-i*k)*C(n,i)*now,now*=fk;
	cout<<res.x;
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3628kb

input:

2 2 1

output:

4

result:

ok answer is '4'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3492kb

input:

1 1 1

output:

0

result:

ok answer is '0'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

24 120 30

output:

379268651

result:

ok answer is '379268651'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3756kb

input:

1451 1598 1130

output:

884873572

result:

ok answer is '884873572'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3756kb

input:

1324 1742 1033

output:

856733047

result:

ok answer is '856733047'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

1378 1614 1335

output:

869903701

result:

ok answer is '869903701'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3688kb

input:

1071 1907 1281

output:

327700529

result:

ok answer is '327700529'

Test #8:

score: 0
Accepted
time: 2ms
memory: 3796kb

input:

1204 1337 1277

output:

475981175

result:

ok answer is '475981175'

Test #9:

score: 0
Accepted
time: 2ms
memory: 3536kb

input:

146 246 100

output:

404402509

result:

ok answer is '404402509'

Test #10:

score: 0
Accepted
time: 2ms
memory: 3732kb

input:

226 183 144

output:

351921989

result:

ok answer is '351921989'

Test #11:

score: 0
Accepted
time: 2ms
memory: 3576kb

input:

234 287 158

output:

658959115

result:

ok answer is '658959115'

Test #12:

score: 0
Accepted
time: 2ms
memory: 3660kb

input:

242 156 122

output:

325586111

result:

ok answer is '325586111'

Test #13:

score: 0
Accepted
time: 2ms
memory: 3676kb

input:

168 271 135

output:

181613866

result:

ok answer is '181613866'

Test #14:

score: 0
Accepted
time: 2ms
memory: 3672kb

input:

22 25 1

output:

684860973

result:

ok answer is '684860973'

Test #15:

score: 0
Accepted
time: 2ms
memory: 3504kb

input:

45 22 15

output:

217501624

result:

ok answer is '217501624'

Test #16:

score: 0
Accepted
time: 2ms
memory: 3652kb

input:

47 29 16

output:

690840771

result:

ok answer is '690840771'

Test #17:

score: 0
Accepted
time: 2ms
memory: 3668kb

input:

2 25 25

output:

660660974

result:

ok answer is '660660974'

Test #18:

score: 0
Accepted
time: 1ms
memory: 3524kb

input:

32 34 11

output:

133387056

result:

ok answer is '133387056'

Test #19:

score: 0
Accepted
time: 12ms
memory: 12744kb

input:

88196 118335 104471

output:

7192211

result:

ok answer is '7192211'

Test #20:

score: 0
Accepted
time: 5ms
memory: 10152kb

input:

142215 57117 51272

output:

627598793

result:

ok answer is '627598793'

Test #21:

score: 0
Accepted
time: 10ms
memory: 9080kb

input:

102255 60360 51525

output:

447649003

result:

ok answer is '447649003'

Test #22:

score: 0
Accepted
time: 9ms
memory: 11220kb

input:

132449 83413 54230

output:

215816803

result:

ok answer is '215816803'

Test #23:

score: 0
Accepted
time: 8ms
memory: 10704kb

input:

68499 95762 77190

output:

393029560

result:

ok answer is '393029560'

Test #24:

score: 0
Accepted
time: 100ms
memory: 61932kb

input:

751951 751951 1

output:

804170883

result:

ok answer is '804170883'

Test #25:

score: 0
Accepted
time: 20ms
memory: 30740kb

input:

804420 1962 410

output:

869056555

result:

ok answer is '869056555'

Test #26:

score: 0
Accepted
time: 35ms
memory: 34068kb

input:

828607 63739 13

output:

926542030

result:

ok answer is '926542030'

Test #27:

score: 0
Accepted
time: 20ms
memory: 21724kb

input:

472167 20529 23

output:

142703540

result:

ok answer is '142703540'

Test #28:

score: 0
Accepted
time: 43ms
memory: 31664kb

input:

363438 363438 1

output:

764563597

result:

ok answer is '764563597'

Test #29:

score: 0
Accepted
time: 114ms
memory: 83380kb

input:

1000000 1000000 628333

output:

283487375

result:

ok answer is '283487375'

Test #30:

score: 0
Accepted
time: 110ms
memory: 87580kb

input:

1000000 1000000 900084

output:

651386967

result:

ok answer is '651386967'

Test #31:

score: 0
Accepted
time: 132ms
memory: 81188kb

input:

1000000 1000000 27328

output:

621963453

result:

ok answer is '621963453'

Test #32:

score: 0
Accepted
time: 123ms
memory: 81904kb

input:

1000000 1000000 538409

output:

997879100

result:

ok answer is '997879100'

Test #33:

score: 0
Accepted
time: 131ms
memory: 88024kb

input:

1000000 1000000 928121

output:

964724707

result:

ok answer is '964724707'

Test #34:

score: 0
Accepted
time: 74ms
memory: 59364kb

input:

685624 665877 563708

output:

257429683

result:

ok answer is '257429683'

Test #35:

score: 0
Accepted
time: 102ms
memory: 71980kb

input:

692290 942095 553970

output:

82511143

result:

ok answer is '82511143'

Test #36:

score: 0
Accepted
time: 86ms
memory: 63680kb

input:

579579 765702 631728

output:

954001361

result:

ok answer is '954001361'

Test #37:

score: 0
Accepted
time: 83ms
memory: 59424kb

input:

756854 634736 567170

output:

393747028

result:

ok answer is '393747028'

Test #38:

score: 0
Accepted
time: 105ms
memory: 72968kb

input:

649175 997874 511181

output:

242172216

result:

ok answer is '242172216'

Test #39:

score: 0
Accepted
time: 126ms
memory: 85672kb

input:

786431 1000000 999999

output:

627359027

result:

ok answer is '627359027'