QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#645384#8023. The Journey of Geor AutumnATM12345#AC ✓177ms316412kbC++17869b2024-10-16 18:02:352024-10-16 18:02:47

Judging History

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

  • [2024-10-16 18:02:47]
  • 评测
  • 测评结果:AC
  • 用时:177ms
  • 内存:316412kb
  • [2024-10-16 18:02:35]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define Ma 10000005
#define mod 998244353
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;


ll mul[Ma],pre[Ma];

ll n,k;


ll po(ll p,ll x=mod-2)
{
	ll sum=1;
	while (x)
	{
		if (x&1) sum=sum*p%mod;
		p=p*p%mod;
		x>>=1;
	}
	return sum;
}



ll dp[Ma],sum[Ma];

void sol()
{
	cin>>n>>k;
	mul[0]=1;
	for (ll i=1;i<=n;i++)
		mul[i]=mul[i-1]*i%mod;
	pre[n]=po(mul[n]);
	for (ll i=n-1;i>=0;i--)
		pre[i]=pre[i+1]*(i+1)%mod;

	for (ll i=1;i<=k;i++)
	{
		dp[i]=mul[i];
		sum[i]=(sum[i-1]+dp[i]*pre[i])%mod;
	}
	for (ll i=k+1;i<=n;i++)
	{
		dp[i]=(sum[i-1]-sum[i-k-1]+mod)%mod*mul[i-1]%mod;
		sum[i]=(sum[i-1]+dp[i]*pre[i])%mod;
	}
	printf("%lld\n",dp[n]);
}


int main()
{
	IOS
	ll tt=1;
	//cin>>tt;
	while (tt--)
		sol();
	return 0;
}

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

詳細信息

Test #1:

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

input:

1 1

output:

1

result:

ok "1"

Test #2:

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

input:

1 2

output:

1

result:

ok "1"

Test #3:

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

input:

1 3

output:

1

result:

ok "1"

Test #4:

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

input:

1 4

output:

1

result:

ok "1"

Test #5:

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

input:

2 1

output:

1

result:

ok "1"

Test #6:

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

input:

2 2

output:

2

result:

ok "2"

Test #7:

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

input:

2 3

output:

2

result:

ok "2"

Test #8:

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

input:

2 4

output:

2

result:

ok "2"

Test #9:

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

input:

3 1

output:

1

result:

ok "1"

Test #10:

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

input:

3 2

output:

4

result:

ok "4"

Test #11:

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

input:

3 3

output:

6

result:

ok "6"

Test #12:

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

input:

3 4

output:

6

result:

ok "6"

Test #13:

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

input:

4 1

output:

1

result:

ok "1"

Test #14:

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

input:

4 2

output:

10

result:

ok "10"

Test #15:

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

input:

4 3

output:

18

result:

ok "18"

Test #16:

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

input:

4 4

output:

24

result:

ok "24"

Test #17:

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

input:

99 50

output:

955866606

result:

ok "955866606"

Test #18:

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

input:

99 70

output:

296999003

result:

ok "296999003"

Test #19:

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

input:

1034 998

output:

637688669

result:

ok "637688669"

Test #20:

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

input:

1099 997

output:

712935289

result:

ok "712935289"

Test #21:

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

input:

10314 998

output:

224695890

result:

ok "224695890"

Test #22:

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

input:

10929 9974

output:

160291286

result:

ok "160291286"

Test #23:

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

input:

103124 99448

output:

695932649

result:

ok "695932649"

Test #24:

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

input:

109139 9937

output:

268916696

result:

ok "268916696"

Test #25:

score: 0
Accepted
time: 19ms
memory: 43988kb

input:

1031234 99238

output:

441457721

result:

ok "441457721"

Test #26:

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

input:

1091239 991237

output:

61047495

result:

ok "61047495"

Test #27:

score: 0
Accepted
time: 104ms
memory: 316412kb

input:

10000000 9982443

output:

224744113

result:

ok "224744113"

Test #28:

score: 0
Accepted
time: 177ms
memory: 316412kb

input:

9999977 5678901

output:

641748125

result:

ok "641748125"

Extra Test:

score: 0
Extra Test Passed