QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#67263#5099. 朝圣道xlwang0 1899ms156912kbC++141.5kb2022-12-10 11:15:492022-12-10 11:15:52

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-10 11:15:52]
  • 评测
  • 测评结果:0
  • 用时:1899ms
  • 内存:156912kb
  • [2022-12-10 11:15:49]
  • 提交

answer

#include <bits/stdc++.h>
#include "pilgrimage.h"
#define ll long long
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
const int Maxn=3e3+20;
ll f[Maxn][Maxn<<1];
inline ll ksm(ll x,ll y,ll mod){
	ll sum=1;
	while(y){
		if(y&1) sum=sum*x%mod;
		y=y/2;
		x=x*x%mod;
	}
	return sum;
}
int x,y;
inline void exgcd(int a,int b){
	if(b==0){
		x=1;
		y=0;
		return;
	}
	exgcd(b,a%b);
	int t=x;
	x=y;
	y=t-a/b*y;      
}
int mod;
const int Maxm=1e6+10;
int ans[Maxn];
int fac[Maxm],ifac[Maxm];
int p1,p2,p3;
void init(int o, int p){
	mod=p;
	f[0][3005]=1;
	x=y=0;
	exgcd(4,p);
	p1=p3=(x+p)%p;
	x=y=0;
	exgcd(2,p);
	p2=(x+p)%p;
	fr(i,1,3000) fr(j,1,6020) f[i][j]=(f[i-1][j]*p2%p+f[i-1][j-1]*p3%p+f[i-1][j+1]*p1%p)%p;
	fr(n,1,3000) fr(i,1,6020) ans[n]+=1ll*abs(i-3005)*f[n][i]%mod,ans[n]%=mod;
	fac[0]=ifac[0]=1;
	int N=1e6;
	fr(i,1,N) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[N]=ksm(fac[N],mod-2,mod);
	rf(i,N-1,1) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	// fr(i,2990,3015) printf("f[%lld]=%lld\n",abs(i-3005),f[7][i]);
}
inline int C(long long x,long long y){
	if(x<=1000000 && y<=1000000) return 1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;
	return 1ll*C(x/mod,y/mod)*C(x%mod,y%mod)%mod;
}
int ask(long long n){
	// printf("%lld %lld\n",n,p2);
	if(n==1){
		return p2;
	}
	n-=2;
	long long answer;
	answer=ksm(p2,2*n+2,mod);
	// printf("%lld %lld\n",n,answer);
	answer=answer*(2*n+3)%mod;
	answer=answer*C(2*n+1,n)%mod;
	return answer;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 864ms
memory: 156912kb

input:

1 910276 554767
6
10
7
4
10
12
9
3
3
5
7
10
5
6
1
6
3
9
6
8
12
11
8
2
12
5
9
3
8
2
12
11
2
3
4
9
2
5
5
11
6
4
8
11
3
9
2
2
8
9
2
8
9
6
2
9
2
10
10
7
5
6
4
4
11
12
8
8
2
2
4
3
3
5
6
6
8
11
6
9
9
3
4
1
2
2
6
9
9
2
3
2
12
6
1
7
2
4
12
11
4
7
6
3
9
4
6
5
3
3
12
6
2
1
1
7
2
6
5
9
11
6
3
4
11
1
2
4
5
4
10...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
277384
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
277384
0
0
0
0
0
0
0
0
0
0
277384
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
277384
277384
0
0
0
0
0
0
0
0
0
0
277384
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 1st numbers differ - expected: '5419', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 789ms
memory: 152700kb

input:

3 1 334547
8234

output:

0

result:

wrong answer 1st numbers differ - expected: '179079', found: '0'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 1899ms
memory: 156648kb

input:

6 958477 522361
280121915553826833
734266539148641647
72849162479700582
274266741463686096
60278972064195458
828423669427600612
571432949203039978
518511460268700898
486268614705621285
19216283231217074
611458416727512530
175147354285288662
799769622289998997
400123443628688299
145546980862133838
40...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 12th numbers differ - expected: '193620', found: '0'

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Wrong Answer

Test #33:

score: 0
Wrong Answer
time: 779ms
memory: 152928kb

input:

8 9963 251
831797004675585320
494759973681332858
701341496127272302
252910460485222469
250965009655458584
366193481309061299
633134388675839346
791999098066205672
196620805863610860
363773642045280947
466508590762410710
407790578717064135
181590911404670570
570642047249889864
70138464625729452
23634...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 25th numbers differ - expected: '204', found: '0'

Subtask #9:

score: 0
Skipped

Dependency #2:

0%