QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#91101#4900. 数列重排xywCompile Error//C++141.3kb2023-03-27 12:09:522023-03-27 12:09:54

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-27 12:09:54]
  • 评测
  • [2023-03-27 12:09:52]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int _=1e7+7,mod=998244353;
int m,l,r,X,n,pw[_],ans[_],res,Sum[_];
char s[_];
ll calc(int i,int j,int s0,int s1){
	int mid=j/2,P=s1-j;ll S=0,SS=0;
	S+=(ll)mid*(s0-i+1)+(ll)(j-mid)*(s0-i+1);
	SS+=(ll)mid*(s1-mid)+(ll)(j-mid)*(s1-(j-mid));
	mid=P/(s0/i-1);int sb=P-(s0/i-1)*mid,sa=(s0/i-1)-sb;
	S+=(ll)sa*mid*(s0-2*i+2)+(ll)sb*(mid+1)*(s0-2*i+2);
	SS+=(ll)sa*mid*(s1-mid)+(ll)sb*(mid+1)*(s1-(mid+1));
	return S+SS/2;
}
void solve(){
	for(int i=l;i<=r;i++){
		if(i==0||m==1){res^=pw[i]*((ll)(n+1)*n/2%mod)%mod;continue;}
		int s0=Sum[i-1],s1,sum=0;
		s1=n-s0;sum=((ll)s0*(s0+1)/2-((2ll*s0-i+2)*(i-1)/2))%mod;
		if(s0/i>1){
			int x=2*i,qqq=s1-2*i;
			x+=qqq/(s0/i+1)*2;
			if(s1<2*i)x=s1;
			sum+=calc(i,x,s0,s1);
		}else {
			int mid=s1/2;ll S=0,SS=0;
			S+=(ll)mid*(s0-i+1);
			SS+=(ll)mid*(s1-mid);
			S+=(ll)(s1-mid)*(s0-i+1);
			SS+=(ll)(s1-mid)*(s1-(s1-mid));
			sum+=S+SS/2;
		}
		sum=(sum+Max%mod)%mod;
		res^=((ll)pw[i]*sum%mod);
	}
	printf("%d\n",res);
}
int main(){
	scanf("%d%d%d%d",&m,&l,&r,&X);
	scanf("%s",s);pw[0]=1;
	for(int i=1;i<=m;i++)
		pw[i]=(ll)pw[i-1]*233%mod;
	Sum[0]=X+s[0]-'0';
	for(int i=1;i<m;i++)
		Sum[i]=Sum[i-1]+X+s[i]-'0';
	n=X*m;
	for(int i=0;i<m;i++)n+=s[i]-'0';
	solve();
	return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:34:26: error: ‘Max’ was not declared in this scope
   34 |                 sum=(sum+Max%mod)%mod;
      |                          ^~~
answer.code: In function ‘int main()’:
answer.code:40:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |         scanf("%d%d%d%d",&m,&l,&r,&X);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
answer.code:41:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   41 |         scanf("%s",s);pw[0]=1;
      |         ~~~~~^~~~~~~~