QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#49898#4807. Melborp LacissalcCrysflyAC ✓83ms5888kbC++172.3kb2022-09-23 23:04:292022-09-23 23:04:31

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-23 23:04:31]
  • 评测
  • 测评结果:AC
  • 用时:83ms
  • 内存:5888kb
  • [2022-09-23 23:04:29]
  • 提交

answer

#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;
}

#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;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
};
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 200005
#define inf 0x3f3f3f3f

int n,k,t;

modint f[66][2105],g[66][2105];

signed main()
{
	n=read()+1,k=read(),t=read();
	initC(70);
	f[0][0]=1;
	For(i,0,k-1){
		if(i>0){
			For(j,1,n)
				For(x,0,t)
					if(f[j][x].x){
						For(o,0,n-j)
							g[j+o][x+o*(o-1)/2]+=f[j][x]*ifac[o];
					}
			For(j,1,n)
				For(x,0,t)
					f[j][x]=g[j][x],g[j][x]=0;
		}else{
			For(o,1,n)
				f[o][o*(o-1)/2]=ifac[o-1];
		}
	}
	modint res=f[n][t]*fac[n-1];
	cout<<res.x;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 5724kb

input:

2 5 1

output:

12

result:

ok 1 number(s): "12"

Test #2:

score: 0
Accepted
time: 3ms
memory: 5656kb

input:

7 10 15

output:

2016

result:

ok 1 number(s): "2016"

Test #3:

score: 0
Accepted
time: 13ms
memory: 5800kb

input:

46 50 171

output:

645560469

result:

ok 1 number(s): "645560469"

Test #4:

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

input:

64 64 0

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: 0
Accepted
time: 4ms
memory: 5652kb

input:

64 64 1

output:

326126263

result:

ok 1 number(s): "326126263"

Test #6:

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

input:

63 64 0

output:

4476118

result:

ok 1 number(s): "4476118"

Test #7:

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

input:

11 45 14

output:

963276342

result:

ok 1 number(s): "963276342"

Test #8:

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

input:

35 20 565

output:

0

result:

ok 1 number(s): "0"

Test #9:

score: 0
Accepted
time: 3ms
memory: 5812kb

input:

3 64 5

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 6ms
memory: 5660kb

input:

35 45 153

output:

181934997

result:

ok 1 number(s): "181934997"

Test #11:

score: 0
Accepted
time: 3ms
memory: 5724kb

input:

3 25 5

output:

0

result:

ok 1 number(s): "0"

Test #12:

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

input:

35 5 373

output:

740122840

result:

ok 1 number(s): "740122840"

Test #13:

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

input:

3 50 5

output:

0

result:

ok 1 number(s): "0"

Test #14:

score: 0
Accepted
time: 6ms
memory: 5652kb

input:

35 30 592

output:

0

result:

ok 1 number(s): "0"

Test #15:

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

input:

3 11 1

output:

540

result:

ok 1 number(s): "540"

Test #16:

score: 0
Accepted
time: 6ms
memory: 5800kb

input:

35 55 352

output:

656633208

result:

ok 1 number(s): "656633208"

Test #17:

score: 0
Accepted
time: 14ms
memory: 5724kb

input:

54 38 356

output:

215089708

result:

ok 1 number(s): "215089708"

Test #18:

score: 0
Accepted
time: 3ms
memory: 5812kb

input:

22 19 189

output:

0

result:

ok 1 number(s): "0"

Test #19:

score: 0
Accepted
time: 28ms
memory: 5724kb

input:

54 63 401

output:

987604839

result:

ok 1 number(s): "987604839"

Test #20:

score: 0
Accepted
time: 3ms
memory: 5716kb

input:

22 43 171

output:

827743481

result:

ok 1 number(s): "827743481"

Test #21:

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

input:

54 24 446

output:

551546514

result:

ok 1 number(s): "551546514"

Test #22:

score: 0
Accepted
time: 3ms
memory: 5796kb

input:

22 4 152

output:

0

result:

ok 1 number(s): "0"

Test #23:

score: 0
Accepted
time: 33ms
memory: 5732kb

input:

54 48 1306

output:

0

result:

ok 1 number(s): "0"

Test #24:

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

input:

22 29 7

output:

374430631

result:

ok 1 number(s): "374430631"

Test #25:

score: 0
Accepted
time: 7ms
memory: 5600kb

input:

54 9 1351

output:

0

result:

ok 1 number(s): "0"

Test #26:

score: 0
Accepted
time: 3ms
memory: 5748kb

input:

22 54 5

output:

267958047

result:

ok 1 number(s): "267958047"

Test #27:

score: 0
Accepted
time: 34ms
memory: 5676kb

input:

64 32 1315

output:

494251101

result:

ok 1 number(s): "494251101"

Test #28:

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

input:

33 12 332

output:

765350074

result:

ok 1 number(s): "765350074"

Test #29:

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

input:

1 57 1

output:

1

result:

ok 1 number(s): "1"

Test #30:

score: 0
Accepted
time: 3ms
memory: 5656kb

input:

33 37 363

output:

0

result:

ok 1 number(s): "0"

Test #31:

score: 0
Accepted
time: 3ms
memory: 5656kb

input:

1 17 0

output:

16

result:

ok 1 number(s): "16"

Test #32:

score: 0
Accepted
time: 7ms
memory: 5824kb

input:

33 62 148

output:

871819399

result:

ok 1 number(s): "871819399"

Test #33:

score: 0
Accepted
time: 3ms
memory: 5840kb

input:

1 42 0

output:

41

result:

ok 1 number(s): "41"

Test #34:

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

input:

33 23 179

output:

23699248

result:

ok 1 number(s): "23699248"

Test #35:

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

input:

1 3 1

output:

1

result:

ok 1 number(s): "1"

Test #36:

score: 0
Accepted
time: 3ms
memory: 5724kb

input:

33 47 211

output:

267909794

result:

ok 1 number(s): "267909794"

Test #37:

score: 0
Accepted
time: 3ms
memory: 5728kb

input:

11 26 32

output:

0

result:

ok 1 number(s): "0"

Test #38:

score: 0
Accepted
time: 4ms
memory: 5720kb

input:

43 6 579

output:

280289125

result:

ok 1 number(s): "280289125"

Test #39:

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

input:

11 50 5

output:

865381083

result:

ok 1 number(s): "865381083"

Test #40:

score: 0
Accepted
time: 11ms
memory: 5812kb

input:

43 31 750

output:

0

result:

ok 1 number(s): "0"

Test #41:

score: 0
Accepted
time: 4ms
memory: 5692kb

input:

11 11 12

output:

753565341

result:

ok 1 number(s): "753565341"

Test #42:

score: 0
Accepted
time: 14ms
memory: 5652kb

input:

43 56 290

output:

575236094

result:

ok 1 number(s): "575236094"

Test #43:

score: 0
Accepted
time: 3ms
memory: 5672kb

input:

11 36 52

output:

0

result:

ok 1 number(s): "0"

Test #44:

score: 0
Accepted
time: 4ms
memory: 5736kb

input:

44 16 0

output:

0

result:

ok 1 number(s): "0"

Test #45:

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

input:

12 61 31

output:

682427534

result:

ok 1 number(s): "682427534"

Test #46:

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

input:

44 41 365

output:

759457870

result:

ok 1 number(s): "759457870"

Test #47:

score: 0
Accepted
time: 3ms
memory: 5692kb

input:

22 19 70

output:

247296498

result:

ok 1 number(s): "247296498"

Test #48:

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

input:

54 64 444

output:

418216086

result:

ok 1 number(s): "418216086"

Test #49:

score: 0
Accepted
time: 4ms
memory: 5828kb

input:

22 44 52

output:

779702126

result:

ok 1 number(s): "779702126"

Test #50:

score: 0
Accepted
time: 18ms
memory: 5724kb

input:

54 25 1303

output:

0

result:

ok 1 number(s): "0"

Test #51:

score: 0
Accepted
time: 3ms
memory: 5724kb

input:

22 5 49

output:

219556981

result:

ok 1 number(s): "219556981"

Test #52:

score: 0
Accepted
time: 33ms
memory: 5660kb

input:

54 49 1269

output:

0

result:

ok 1 number(s): "0"

Test #53:

score: 0
Accepted
time: 3ms
memory: 5832kb

input:

22 30 14

output:

719775605

result:

ok 1 number(s): "719775605"

Test #54:

score: 0
Accepted
time: 3ms
memory: 5672kb

input:

54 10 1314

output:

0

result:

ok 1 number(s): "0"

Test #55:

score: 0
Accepted
time: 3ms
memory: 5740kb

input:

22 54 12

output:

325137058

result:

ok 1 number(s): "325137058"

Test #56:

score: 0
Accepted
time: 24ms
memory: 5728kb

input:

54 35 1359

output:

0

result:

ok 1 number(s): "0"

Test #57:

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

input:

33 13 335

output:

202725820

result:

ok 1 number(s): "202725820"

Test #58:

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

input:

64 64 2080

output:

1

result:

ok 1 number(s): "1"

Test #59:

score: 0
Accepted
time: 3ms
memory: 5720kb

input:

1 1 0

output:

0

result:

ok 1 number(s): "0"

Test #60:

score: 0
Accepted
time: 3ms
memory: 5728kb

input:

1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #61:

score: 0
Accepted
time: 78ms
memory: 5728kb

input:

63 63 2016

output:

1

result:

ok 1 number(s): "1"