QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#762689#8023. The Journey of Geor AutumnMeathermAC ✓152ms121036kbC++141.1kb2024-11-19 16:13:172024-11-19 16:13:19

Judging History

This is the latest submission verdict.

  • [2024-11-19 16:13:19]
  • Judged
  • Verdict: AC
  • Time: 152ms
  • Memory: 121036kb
  • [2024-11-19 16:13:17]
  • Submitted

answer

/*
I know this sky loves you
いずれ全て
変わってしまったって
空は青いだろうよ
*/

# include <bits/stdc++.h>

const int N=10000010,INF=0x3f3f3f3f,mod=998244353,V=N-10;

inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-') f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}

int n,k;

inline int adc(int a,int b){return (a+b>=mod)?(a+b-mod):(a+b);}
inline int dec(int a,int b){return (a<b)?(a-b+mod):(a-b);}
inline int mul(int a,int b){return 1ll*a*b%mod;}
inline void add(int &a,int b){a=adc(a,b);}
inline void del(int &a,int b){a=dec(a,b);}

int inv[N];

inline void init(void){
	inv[1]=1;
	for(int i=2;i<=V;++i) inv[i]=mul(inv[mod%i],dec(mod,mod/i));
	return;
}

int f[N],g[N];

int main(void){
//	freopen("b.in","r",stdin);
//	freopen("b.out","w",stdout);
	init();
	
	n=read(),k=read();
	g[0]=1;
	for(int i=1;i<=n-1;++i) g[0]=mul(g[0],i);
	
	for(int i=1;i<=n;++i){
		f[i]=g[i-1];
		if(i-k-1>=0) del(f[i],g[i-k-1]);
		g[i]=adc(g[i-1],mul(inv[n-i],f[i]));
	}
	
	printf("%d",f[n]);

	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 41ms
memory: 45176kb

input:

1 1

output:

1

result:

ok "1"

Test #2:

score: 0
Accepted
time: 41ms
memory: 46876kb

input:

1 2

output:

1

result:

ok "1"

Test #3:

score: 0
Accepted
time: 41ms
memory: 45576kb

input:

1 3

output:

1

result:

ok "1"

Test #4:

score: 0
Accepted
time: 45ms
memory: 45964kb

input:

1 4

output:

1

result:

ok "1"

Test #5:

score: 0
Accepted
time: 42ms
memory: 44944kb

input:

2 1

output:

1

result:

ok "1"

Test #6:

score: 0
Accepted
time: 42ms
memory: 45048kb

input:

2 2

output:

2

result:

ok "2"

Test #7:

score: 0
Accepted
time: 41ms
memory: 45416kb

input:

2 3

output:

2

result:

ok "2"

Test #8:

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

input:

2 4

output:

2

result:

ok "2"

Test #9:

score: 0
Accepted
time: 42ms
memory: 45300kb

input:

3 1

output:

1

result:

ok "1"

Test #10:

score: 0
Accepted
time: 47ms
memory: 46840kb

input:

3 2

output:

4

result:

ok "4"

Test #11:

score: 0
Accepted
time: 46ms
memory: 46820kb

input:

3 3

output:

6

result:

ok "6"

Test #12:

score: 0
Accepted
time: 40ms
memory: 46628kb

input:

3 4

output:

6

result:

ok "6"

Test #13:

score: 0
Accepted
time: 30ms
memory: 46516kb

input:

4 1

output:

1

result:

ok "1"

Test #14:

score: 0
Accepted
time: 47ms
memory: 45704kb

input:

4 2

output:

10

result:

ok "10"

Test #15:

score: 0
Accepted
time: 42ms
memory: 46272kb

input:

4 3

output:

18

result:

ok "18"

Test #16:

score: 0
Accepted
time: 29ms
memory: 44872kb

input:

4 4

output:

24

result:

ok "24"

Test #17:

score: 0
Accepted
time: 48ms
memory: 46948kb

input:

99 50

output:

955866606

result:

ok "955866606"

Test #18:

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

input:

99 70

output:

296999003

result:

ok "296999003"

Test #19:

score: 0
Accepted
time: 51ms
memory: 46104kb

input:

1034 998

output:

637688669

result:

ok "637688669"

Test #20:

score: 0
Accepted
time: 47ms
memory: 46692kb

input:

1099 997

output:

712935289

result:

ok "712935289"

Test #21:

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

input:

10314 998

output:

224695890

result:

ok "224695890"

Test #22:

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

input:

10929 9974

output:

160291286

result:

ok "160291286"

Test #23:

score: 0
Accepted
time: 39ms
memory: 45812kb

input:

103124 99448

output:

695932649

result:

ok "695932649"

Test #24:

score: 0
Accepted
time: 49ms
memory: 49212kb

input:

109139 9937

output:

268916696

result:

ok "268916696"

Test #25:

score: 0
Accepted
time: 57ms
memory: 55440kb

input:

1031234 99238

output:

441457721

result:

ok "441457721"

Test #26:

score: 0
Accepted
time: 49ms
memory: 55364kb

input:

1091239 991237

output:

61047495

result:

ok "61047495"

Test #27:

score: 0
Accepted
time: 148ms
memory: 121036kb

input:

10000000 9982443

output:

224744113

result:

ok "224744113"

Test #28:

score: 0
Accepted
time: 152ms
memory: 120980kb

input:

9999977 5678901

output:

641748125

result:

ok "641748125"

Extra Test:

score: 0
Extra Test Passed