QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#688926#1085. Brave Seekers of Unicorns0xyzRE 0ms0kbC++14494b2024-10-30 14:19:412024-10-30 14:19:47

Judging History

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

  • [2024-10-30 14:19:47]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-30 14:19:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int _=1e6+5;
int n,p,l[_],s[_],f[_],c[_];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>p;
	s[0]=f[0]=1;l[0]=-1;
	for(int i=1,x;i<=n;i++){
		l[i]=l[i>>1]+1;x=i^(1<<l[i]);
		if(x&&!c[x]){
			if(x==(1<<l[x]))c[x]=(s[2*x-1]-s[x-1]+p)%p;
			else c[x]=(c[1<<l[x]]+c[x-(1<<l[x])])%p;
		}
		f[i]=(s[i-1]-c[x]+p)%p;
		s[i]=(s[i-1]+f[i])%p;
	}
	cout<<(s[n]+p-1)%p<<'\n';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

1

output:


result: