QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#691709#8023. The Journey of Geor Autumnlouhao088TL 915ms3712kbC++23628b2024-10-31 12:43:342024-10-31 12:43:34

Judging History

This is the latest submission verdict.

  • [2024-10-31 12:43:34]
  • Judged
  • Verdict: TL
  • Time: 915ms
  • Memory: 3712kb
  • [2024-10-31 12:43:34]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define lowbit(i) (i&(-i))
const int mod=998244353,maxn=1e7+5,M=100005;
#define int long long
#define pb push_back
inline int read(){
	char ch=getchar();int x=0;bool f=0;
	for(;!isdigit(ch);ch=getchar())if(ch=='-')f=1;
	for(;isdigit(ch);ch=getchar())x=(x<<1)+(x<<3)+(ch^48);
	if(f==1)x=-x;return x;
}
int f[maxn],n,k;
signed main(){
	n=read(),k=read();
	f[0]=1;
	for(int i=1;i<=n;i++){
		for(int j=max(0ll,i-k);j<i;j++){
			int res=f[j];
			for(int l=i-1;l>=j+1;l--)
				res=res*l%mod;
			f[i]=f[i]+res;
			f[i]%=mod;
		}
	}
	cout<<f[n]<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1 1

output:

1

result:

ok "1"

Test #2:

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

input:

1 2

output:

1

result:

ok "1"

Test #3:

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

input:

1 3

output:

1

result:

ok "1"

Test #4:

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

input:

1 4

output:

1

result:

ok "1"

Test #5:

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

input:

2 1

output:

1

result:

ok "1"

Test #6:

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

input:

2 2

output:

2

result:

ok "2"

Test #7:

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

input:

2 3

output:

2

result:

ok "2"

Test #8:

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

input:

2 4

output:

2

result:

ok "2"

Test #9:

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

input:

3 1

output:

1

result:

ok "1"

Test #10:

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

input:

3 2

output:

4

result:

ok "4"

Test #11:

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

input:

3 3

output:

6

result:

ok "6"

Test #12:

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

input:

3 4

output:

6

result:

ok "6"

Test #13:

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

input:

4 1

output:

1

result:

ok "1"

Test #14:

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

input:

4 2

output:

10

result:

ok "10"

Test #15:

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

input:

4 3

output:

18

result:

ok "18"

Test #16:

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

input:

4 4

output:

24

result:

ok "24"

Test #17:

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

input:

99 50

output:

955866606

result:

ok "955866606"

Test #18:

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

input:

99 70

output:

296999003

result:

ok "296999003"

Test #19:

score: 0
Accepted
time: 778ms
memory: 3712kb

input:

1034 998

output:

637688669

result:

ok "637688669"

Test #20:

score: 0
Accepted
time: 915ms
memory: 3644kb

input:

1099 997

output:

712935289

result:

ok "712935289"

Test #21:

score: -100
Time Limit Exceeded

input:

10314 998

output:


result: