QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#279943#7873. Since A LightCrysfly32 238ms15500kbC++173.1kb2023-12-09 12:35:282023-12-09 12:35:28

Judging History

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

  • [2023-12-09 12:35:28]
  • 评测
  • 测评结果:32
  • 用时:238ms
  • 内存:15500kb
  • [2023-12-09 12:35:28]
  • 提交

answer

// what is matter? never mind. 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#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 ll long long
#define ull unsigned 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;}
	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 1000005
#define inf 0x3f3f3f3f

int n,d;
modint res[maxn];

modint C2(int n,int m){
	return C(n+m-1,m-1);
}
modint F(int n,int d){
	if(n<d)return 0;
	return C((n+d)/2,d);
}

modint sum[maxn];
modint tmp[maxn];

signed main()
{
	n=read(),d=read();
	For(i,0,n){
	//	cout<<"i: "<<i<<"\n";
		for(int j=i-1;j>=0;j-=2) res[i]+=res[j];
	//	For(k,0,d)cout<<F(i,k).x<<" ";cout<<"\n";
		For(k,0,d) res[i]+=F(i,k)*F(i,d-k);
		For(k,0,d-2) sum[i]+=F(i,k)*F(i,d-2-k);
		sum[i]+=sum[i-2];
		res[i]-=sum[i-1];
//		cout<<"res "<<res[i].x<<"\n";
//		for(int j=i-1;j>=0;j-=2){
//			For(k,0,d-2)
//				res[i]-=F(j,k)*F(j,d-2-k);
//		}
	//	cout<<"res "<<res[i].x<<"\n";
//		For(k,0,d)cout<<tmp[k].x<<" "<<F(i,k).x<<"\n";
//		For(k,0,d)assert(tmp[k].x==F(i,k).x);
//		cout<<"res "<<res[i].x<<"\n";
	}
	res[n]*=((mod+1)/2);
	cout<<res[n].x;
	return 0;
}
/*

*/

详细

Subtask #1:

score: 1
Accepted

Test #1:

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

input:

1 1

output:

1

result:

ok single line: '1'

Test #2:

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

input:

2 1

output:

2

result:

ok single line: '2'

Test #3:

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

input:

3 2

output:

3

result:

ok single line: '3'

Test #4:

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

input:

4 4

output:

5

result:

ok single line: '5'

Test #5:

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

input:

5 7

output:

2

result:

ok single line: '2'

Test #6:

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

input:

6 4

output:

41

result:

ok single line: '41'

Test #7:

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

input:

7 11

output:

2

result:

ok single line: '2'

Test #8:

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

input:

8 8

output:

175

result:

ok single line: '175'

Test #9:

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

input:

9 10

output:

298

result:

ok single line: '298'

Test #10:

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

input:

10 3

output:

392

result:

ok single line: '392'

Test #11:

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

input:

11 8

output:

3785

result:

ok single line: '3785'

Test #12:

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

input:

12 15

output:

1422

result:

ok single line: '1422'

Test #13:

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

input:

13 17

output:

2008

result:

ok single line: '2008'

Test #14:

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

input:

14 16

output:

21508

result:

ok single line: '21508'

Test #15:

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

input:

15 1

output:

1596

result:

ok single line: '1596'

Test #16:

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

input:

16 28

output:

29

result:

ok single line: '29'

Test #17:

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

input:

17 6

output:

98086

result:

ok single line: '98086'

Test #18:

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

input:

18 11

output:

1478534

result:

ok single line: '1478534'

Test #19:

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

input:

19 25

output:

250068

result:

ok single line: '250068'

Test #20:

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

input:

20 27

output:

355418

result:

ok single line: '355418'

Test #21:

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

input:

21 23

output:

13517834

result:

ok single line: '13517834'

Test #22:

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

input:

22 4

output:

315460

result:

ok single line: '315460'

Test #23:

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

input:

23 37

output:

18428

result:

ok single line: '18428'

Test #24:

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

input:

24 18

output:

647287901

result:

ok single line: '647287901'

Test #25:

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

input:

25 40

output:

136655

result:

ok single line: '136655'

Subtask #2:

score: 7
Accepted

Test #26:

score: 7
Accepted
time: 3ms
memory: 15388kb

input:

380 59

output:

718355613

result:

ok single line: '718355613'

Test #27:

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

input:

164 46

output:

353450103

result:

ok single line: '353450103'

Test #28:

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

input:

206 144

output:

910367339

result:

ok single line: '910367339'

Test #29:

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

input:

270 127

output:

78796015

result:

ok single line: '78796015'

Test #30:

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

input:

157 87

output:

705420296

result:

ok single line: '705420296'

Subtask #3:

score: 10
Accepted

Test #31:

score: 10
Accepted
time: 4ms
memory: 15452kb

input:

413 652

output:

170600118

result:

ok single line: '170600118'

Test #32:

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

input:

724 979

output:

677376486

result:

ok single line: '677376486'

Test #33:

score: 0
Accepted
time: 37ms
memory: 15468kb

input:

1667 1699

output:

147640784

result:

ok single line: '147640784'

Test #34:

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

input:

1980 517

output:

276583672

result:

ok single line: '276583672'

Test #35:

score: 0
Accepted
time: 50ms
memory: 15468kb

input:

2000 2000

output:

265422351

result:

ok single line: '265422351'

Subtask #4:

score: 14
Accepted

Test #36:

score: 14
Accepted
time: 238ms
memory: 15500kb

input:

4495 4498

output:

375585699

result:

ok single line: '375585699'

Test #37:

score: 0
Accepted
time: 185ms
memory: 15444kb

input:

4968 2196

output:

844161053

result:

ok single line: '844161053'

Test #38:

score: 0
Accepted
time: 171ms
memory: 15460kb

input:

3967 3143

output:

496535114

result:

ok single line: '496535114'

Test #39:

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

input:

2406 4205

output:

599052202

result:

ok single line: '599052202'

Test #40:

score: 0
Accepted
time: 172ms
memory: 15460kb

input:

3942 3259

output:

110001226

result:

ok single line: '110001226'

Subtask #5:

score: 0
Time Limit Exceeded

Test #41:

score: 0
Time Limit Exceeded

input:

158314621 32

output:


result:


Subtask #6:

score: 0
Time Limit Exceeded

Test #46:

score: 0
Time Limit Exceeded

input:

812922977 1762

output:


result:


Subtask #7:

score: 0
Time Limit Exceeded

Test #51:

score: 0
Time Limit Exceeded

input:

320076133 78121

output:


result: