QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#762375#8023. The Journey of Geor AutumnyinheeAC ✓178ms121076kbC++141.8kb2024-11-19 14:46:512024-11-19 14:47:06

Judging History

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

  • [2024-11-19 14:47:06]
  • 评测
  • 测评结果:AC
  • 用时:178ms
  • 内存:121076kb
  • [2024-11-19 14:46:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_std{
#define mems(x,y) memset(x,y,sizeof x)
#define Mp make_pair
#define eb emplace_back
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define il inline
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a);i>=(b);i--)
#define go(i,u) for(int i=head[u];i;i=e[i].nxt)
	typedef long long ll;
	typedef pair<int,int> pii;
	template<typename T>
	il void read(T &x){
		int f=1;x=0;char c=gc();
		while(c<'0'||c>'9'){
			if(c=='-'){
				f=-1;
			}
			c=gc();
		}
		while(c>='0'&&c<='9'){
			x=x*10+c-48,c=gc();
		}
		x*=f;
	}
	template<typename T,typename ...Args>
	void read(T &x,Args &...args){
		read(x),read(args...);
	}
	template<typename T>
	il void write(T x){
		char buf[43];int len=0;
		if(x<0){
			pc('-'),x=-x;
		}
		do{
			buf[++len]=x%10,x/=10;
		}while(x);
		while(len){
			pc(buf[len--]+'0');
		}
	}
}
using namespace my_std;
const int N=1e7+7,M=-1,inf=0x3f3f3f3f,mod=998244353;
int n,m,dp[N];
int fac[N],ifac[N];
il int Mod(int x,int y){return x+y>=mod?x+y-mod:x+y;}
il int binom(int x,int y){if(x<0||y<0||x<y){return 0;}return 1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;}
il int qpow(int x,int y){int ret=1;while(y){if(y&1){ret=1ll*ret*x%mod;}x=1ll*x*x%mod,y>>=1;}return ret;}
void initFac(int n){fac[0]=1;rep(i,1,n){fac[i]=1ll*fac[i-1]*i%mod;}ifac[n]=qpow(fac[n],mod-2);drep(i,n-1,0){ifac[i]=1ll*ifac[i+1]*(i+1)%mod;}}
void Yorushika(){
	read(n,m);
	initFac(n);
	dp[0]=1;
	int s=fac[n-1];
	rep(i,1,n){
		dp[i]=1ll*s*ifac[n-i]%mod;
		if(i<n){
			s=Mod(s,1ll*dp[i]*fac[n-i-1]%mod);
			if(i>=m){
				s=Mod(s,mod-1ll*dp[i-m]*fac[n-i+m-1]%mod);
			}
		}
	}
	printf("%d\n",dp[n]);
}
signed main(){
	int t=1;
	//read(t);
	while(t--){
		Yorushika();
	}
}

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

详细

Test #1:

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

input:

1 1

output:

1

result:

ok "1"

Test #2:

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

input:

1 2

output:

1

result:

ok "1"

Test #3:

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

input:

1 3

output:

1

result:

ok "1"

Test #4:

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

input:

1 4

output:

1

result:

ok "1"

Test #5:

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

input:

2 1

output:

1

result:

ok "1"

Test #6:

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

input:

2 2

output:

2

result:

ok "2"

Test #7:

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

input:

2 3

output:

2

result:

ok "2"

Test #8:

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

input:

2 4

output:

2

result:

ok "2"

Test #9:

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

input:

3 1

output:

1

result:

ok "1"

Test #10:

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

input:

3 2

output:

4

result:

ok "4"

Test #11:

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

input:

3 3

output:

6

result:

ok "6"

Test #12:

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

input:

3 4

output:

6

result:

ok "6"

Test #13:

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

input:

4 1

output:

1

result:

ok "1"

Test #14:

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

input:

4 2

output:

10

result:

ok "10"

Test #15:

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

input:

4 3

output:

18

result:

ok "18"

Test #16:

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

input:

4 4

output:

24

result:

ok "24"

Test #17:

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

input:

99 50

output:

955866606

result:

ok "955866606"

Test #18:

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

input:

99 70

output:

296999003

result:

ok "296999003"

Test #19:

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

input:

1034 998

output:

637688669

result:

ok "637688669"

Test #20:

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

input:

1099 997

output:

712935289

result:

ok "712935289"

Test #21:

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

input:

10314 998

output:

224695890

result:

ok "224695890"

Test #22:

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

input:

10929 9974

output:

160291286

result:

ok "160291286"

Test #23:

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

input:

103124 99448

output:

695932649

result:

ok "695932649"

Test #24:

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

input:

109139 9937

output:

268916696

result:

ok "268916696"

Test #25:

score: 0
Accepted
time: 22ms
memory: 21596kb

input:

1031234 99238

output:

441457721

result:

ok "441457721"

Test #26:

score: 0
Accepted
time: 11ms
memory: 21760kb

input:

1091239 991237

output:

61047495

result:

ok "61047495"

Test #27:

score: 0
Accepted
time: 174ms
memory: 121076kb

input:

10000000 9982443

output:

224744113

result:

ok "224744113"

Test #28:

score: 0
Accepted
time: 178ms
memory: 120956kb

input:

9999977 5678901

output:

641748125

result:

ok "641748125"

Extra Test:

score: 0
Extra Test Passed