QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#85169#1064. 移动金币zombie462100 ✓10ms6464kbC++231.1kb2023-03-07 02:15:242023-03-07 02:15:27

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-07 02:15:27]
  • Judged
  • Verdict: 100
  • Time: 10ms
  • Memory: 6464kb
  • [2023-03-07 02:15:24]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define N 150010
#define int long long
int fac[N],ifac[N],d[N],n,m,k;
int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;
		ch=getchar();
	}
	while (ch>='0' && ch<='9'){
		x=x*10+ch-'0';ch=getchar();
	}
	return x*f;
}
void init(int n){
	fac[0]=1;
	for (int i=1;i<=n;++i) fac[i]=1LL*fac[i-1]*i%mod;
	ifac[0]=ifac[1]=1;
	for (int i=2;i<=n;++i) ifac[i]=1LL*(mod-mod/i)*ifac[mod%i]%mod;
	for (int i=2;i<=n;++i) ifac[i]=1LL*ifac[i-1]*ifac[i]%mod;
}
int C(int n,int m){
	return 1LL*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
signed main(){
	n=read(),m=read();init(n);
	n-=m;k=(m+1)/2;d[0]=1;
	for (int i=0;i<=n/4;++i){
		for (int j=0;j<=i && 4*j+2<=k;++j) d[2*i+1]=(d[2*i+1]+1LL*C(k,4*j+2)*d[i-j])%mod;
		d[2*i+2]=d[i+1];
		for (int j=1;j<=i+1 && 4*j<=k;++j) d[2*i+2]=(d[2*i+2]+1LL*C(k,4*j)*d[i+1-j])%mod;
	}
	int ans=0,kk=m-k;
	for (int i=0;i<=n;++i) if (~i&1) ans=(ans+1LL*d[i/2]*C(n-i+kk,kk))%mod;
	ans=(C(n+m,m)-ans+mod)%mod;
	cout<<ans<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 50
Accepted

Test #1:

score: 50
Accepted
time: 2ms
memory: 3556kb

input:

242 49

output:

328585486

result:

ok single line: '328585486'

Test #2:

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

input:

242 47

output:

219114925

result:

ok single line: '219114925'

Test #3:

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

input:

243 50

output:

45372101

result:

ok single line: '45372101'

Test #4:

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

input:

243 47

output:

650410655

result:

ok single line: '650410655'

Test #5:

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

input:

244 47

output:

179262409

result:

ok single line: '179262409'

Test #6:

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

input:

245 50

output:

238336251

result:

ok single line: '238336251'

Test #7:

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

input:

245 48

output:

596598396

result:

ok single line: '596598396'

Test #8:

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

input:

246 46

output:

989539157

result:

ok single line: '989539157'

Test #9:

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

input:

246 46

output:

989539157

result:

ok single line: '989539157'

Test #10:

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

input:

240 50

output:

876085357

result:

ok single line: '876085357'

Subtask #2:

score: 50
Accepted

Dependency #1:

100%
Accepted

Test #11:

score: 50
Accepted
time: 7ms
memory: 6180kb

input:

142791 49

output:

83586215

result:

ok single line: '83586215'

Test #12:

score: 0
Accepted
time: 8ms
memory: 6424kb

input:

145417 47

output:

461460544

result:

ok single line: '461460544'

Test #13:

score: 0
Accepted
time: 10ms
memory: 6464kb

input:

148042 50

output:

990066474

result:

ok single line: '990066474'

Test #14:

score: 0
Accepted
time: 9ms
memory: 6044kb

input:

135668 50

output:

849717347

result:

ok single line: '849717347'

Test #15:

score: 0
Accepted
time: 10ms
memory: 5984kb

input:

138293 48

output:

605810507

result:

ok single line: '605810507'

Test #16:

score: 0
Accepted
time: 10ms
memory: 6144kb

input:

140919 46

output:

842694042

result:

ok single line: '842694042'

Test #17:

score: 0
Accepted
time: 7ms
memory: 6200kb

input:

143544 49

output:

806787086

result:

ok single line: '806787086'

Test #18:

score: 0
Accepted
time: 4ms
memory: 6404kb

input:

146170 49

output:

792539725

result:

ok single line: '792539725'

Test #19:

score: 0
Accepted
time: 5ms
memory: 6296kb

input:

148795 47

output:

445621354

result:

ok single line: '445621354'

Test #20:

score: 0
Accepted
time: 9ms
memory: 6040kb

input:

137925 48

output:

562018157

result:

ok single line: '562018157'