QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#762818#8023. The Journey of Geor AutumnqwqwfAC ✓155ms120864kbC++141.0kb2024-11-19 16:49:042024-11-19 16:49:05

Judging History

This is the latest submission verdict.

  • [2024-11-19 16:49:05]
  • Judged
  • Verdict: AC
  • Time: 155ms
  • Memory: 120864kb
  • [2024-11-19 16:49:04]
  • Submitted

answer

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#pragma GCC optimize("Ofast","unroll-loops","inline")
#include<bits/stdc++.h>
#define ll long long
//#define int ll
#define pb push_back
#define pii pair<int,int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
const int N=1e7+60,M=1e6+20,mod=998244353;
inline void Add(int &x,int y){x+=y;if(x>=mod) x-=mod;}
inline void Del(int &x,int y){x-=y;if(x<0) x+=mod;}
inline int del(int x,int y){x-=y;return x<0?x+mod:x;}
inline int add(int x,int y){x+=y;return x>=mod?x-mod:x;}
int inv[N],n,k,f[N],g[N];
signed main(){
//	freopen("b.in","r",stdin);
//	freopen("b.out","w",stdout);
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	inv[0]=inv[1]=1;for(int i=2;i<N;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	cin>>n>>k;
	f[0]=g[0]=1;
	for(int i=1;i<=n;i++){
		int x=del(g[i-1],i-k-1>=0?g[i-k-1]:0);
		f[i]=1ll*x*inv[i]%mod;
		g[i]=add(g[i-1],f[i]);
	}
	int ans=f[n];
	for(int i=1;i<=n;i++) ans=1ll*ans*i%mod;
	cout<<ans<<'\n';
	return 0;
}

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

詳細信息

Test #1:

score: 100
Accepted
time: 52ms
memory: 45388kb

input:

1 1

output:

1

result:

ok "1"

Test #2:

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

input:

1 2

output:

1

result:

ok "1"

Test #3:

score: 0
Accepted
time: 44ms
memory: 46872kb

input:

1 3

output:

1

result:

ok "1"

Test #4:

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

input:

1 4

output:

1

result:

ok "1"

Test #5:

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

input:

2 1

output:

1

result:

ok "1"

Test #6:

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

input:

2 2

output:

2

result:

ok "2"

Test #7:

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

input:

2 3

output:

2

result:

ok "2"

Test #8:

score: 0
Accepted
time: 43ms
memory: 45492kb

input:

2 4

output:

2

result:

ok "2"

Test #9:

score: 0
Accepted
time: 56ms
memory: 45680kb

input:

3 1

output:

1

result:

ok "1"

Test #10:

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

input:

3 2

output:

4

result:

ok "4"

Test #11:

score: 0
Accepted
time: 54ms
memory: 45484kb

input:

3 3

output:

6

result:

ok "6"

Test #12:

score: 0
Accepted
time: 43ms
memory: 45276kb

input:

3 4

output:

6

result:

ok "6"

Test #13:

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

input:

4 1

output:

1

result:

ok "1"

Test #14:

score: 0
Accepted
time: 55ms
memory: 45532kb

input:

4 2

output:

10

result:

ok "10"

Test #15:

score: 0
Accepted
time: 53ms
memory: 45956kb

input:

4 3

output:

18

result:

ok "18"

Test #16:

score: 0
Accepted
time: 43ms
memory: 45032kb

input:

4 4

output:

24

result:

ok "24"

Test #17:

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

input:

99 50

output:

955866606

result:

ok "955866606"

Test #18:

score: 0
Accepted
time: 52ms
memory: 46072kb

input:

99 70

output:

296999003

result:

ok "296999003"

Test #19:

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

input:

1034 998

output:

637688669

result:

ok "637688669"

Test #20:

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

input:

1099 997

output:

712935289

result:

ok "712935289"

Test #21:

score: 0
Accepted
time: 58ms
memory: 45960kb

input:

10314 998

output:

224695890

result:

ok "224695890"

Test #22:

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

input:

10929 9974

output:

160291286

result:

ok "160291286"

Test #23:

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

input:

103124 99448

output:

695932649

result:

ok "695932649"

Test #24:

score: 0
Accepted
time: 61ms
memory: 45748kb

input:

109139 9937

output:

268916696

result:

ok "268916696"

Test #25:

score: 0
Accepted
time: 61ms
memory: 55248kb

input:

1031234 99238

output:

441457721

result:

ok "441457721"

Test #26:

score: 0
Accepted
time: 59ms
memory: 55368kb

input:

1091239 991237

output:

61047495

result:

ok "61047495"

Test #27:

score: 0
Accepted
time: 145ms
memory: 120848kb

input:

10000000 9982443

output:

224744113

result:

ok "224744113"

Test #28:

score: 0
Accepted
time: 155ms
memory: 120864kb

input:

9999977 5678901

output:

641748125

result:

ok "641748125"

Extra Test:

score: 0
Extra Test Passed