QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#768391#9748. 最大公因数的平方和0xyzCompile Error//C++141.4kb2024-11-21 09:59:542024-11-21 09:59:55

Judging History

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

  • [2024-11-21 09:59:55]
  • 评测
  • [2024-11-21 09:59:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef unsigned int ll;
const ll _=1e5+5,B=320,C=320;
struct qr{ll w,x,y,z;};
vector<qr>q[_];
vector<ll>g[_];
ll u[_],v[_],d[_],a[_],b[_],c[_],f[_],s[_],t[_],w[_],o[_],n,m;
inline void add(ll p,ll k){
	u[p]+=k;v[c[p]]+=k;
}
inline ll sum(ll l,ll r){
	ll w=0;
	if(l+C>=r){
		for(ll i=l;i<=r;i++)w+=u[i];
	}else{
		for(ll i=l;i<=C*c[l];i++)w+=u[i];
		for(ll i=c[l]+1;i<=c[r];i++)w+=v[i];
		for(ll i=C*c[r]+1;i<=r;i++)w+=u[i];
	}
	return w;
}
int main(){
	freopen("qwq.in","r",stdin);
	freopen("qwq.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(ll i=1;i<=n;i++)cin>>a[i],c[i]=(i-1)/C+1;
	for(ll i=1;i<=n;i++)cin>>b[i],d[b[i]]=i;
	o[1]=1;
	for(ll i=1;i<=n;i++)
		for(ll j=2;j*i<=n;j++)o[i*j]-=o[i];
	for(ll i=1;i<=n;i++)
		for(ll j=1;j*i<=n;j++)f[i*j]+=i*i*o[j],g[i*j].push_back(i);
	cin>>m;
	for(ll i=1,x,y,X,Y;i<=m;i++){
		cin>>x>>y>>X>>Y;
		q[x-1].push_back({X,Y,i,-1});
		q[y].push_back({X,Y,i,1});
	}
	for(ll i=1;i<=B;i++){
		for(ll j=1;j<=n;j++)s[j]=s[j-1]+(a[j]%i==0),t[j]=t[j-1]+(b[j]%i==0);
		for(ll j=1;j<=n;j++)
			for(qr k:q[j])w[k.y]+=k.z*f[i]*s[j]*(t[k.x]-t[k.w-1]);
	}
	for(ll i=1;i<=n;i++){
		for(ll j:g[a[i]])
			if(j>B)
				for(ll k=j;k<=n;k+=j)add(d[k],f[j]);
		for(qr j:q[i])w[j.y]+=j.z*sum(j.w,j.x);
	}
	for(ll i=1;i<=m;i++)cout<<w[i]<<'\n';
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:39:41: error: narrowing conversion of ‘-1’ from ‘int’ to ‘ll’ {aka ‘unsigned int’} [-Wnarrowing]
   39 |                 q[x-1].push_back({X,Y,i,-1});
      |                                         ^~
answer.code:24:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |         freopen("qwq.in","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
answer.code:25:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |         freopen("qwq.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~