QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#231389#858. GCD vs. XORlnyxWA 1ms3512kbC++141.4kb2023-10-29 10:06:372023-10-29 10:06:38

Judging History

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

  • [2023-10-29 10:06:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3512kb
  • [2023-10-29 10:06:37]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<algorithm>
namespace IO{
	template<typename T> inline void rd(T &x){
		x=0;bool f=0;char c=0;
		while(c<'0'||c>'9') f|=c=='-',c=getchar();
		while('0'<=c&&c<='9') x=x*10+(c^48),c=getchar();
		x=f?-x:x;
	}
	template<typename T,typename ...Args> inline void rd(T &x,Args &...args){rd(x),rd(args...);}
	template<typename T> inline void wt(char c,T x){
		int stk[114],top=0;
		if(x<0) x=-x,putchar('-');
		do stk[++top]=x%10,x/=10; while(x);
		while(top) putchar(stk[top--]+'0');
		putchar(c);
	}
	template<typename T,typename ...Args> inline void wt(char c,T x,Args ...args){wt(c,x),wt(c,args...);}
	template<typename T,typename ...Args> inline void wt(char s,char c,T x,Args ...args){wt(c,x),wt(c,args...),putchar(s);}
};
using namespace IO;
using namespace std;
typedef long long LL;
const int N=2e6+7;
int n,mx;
int sum[N];
inline void solve(){
	rd(n);
	for(int i=1;i<=n;i++){
		int x; rd(x);
		sum[x]++,mx=max(mx,x);
	}
	LL ans=0;
	for(int d=1;d<=n;d++){
		for(int i=d;i<=mx;i+=d){
			if((i^d)!=i+d) continue;
			// if(sum[i]&&sum[i+d]) cerr<<i<<" "<<d<<endl;
			ans+=1ll*sum[i]*sum[i+d];
		}
	}
	wt('\n',ans);
	for(int i=1;i<=mx;i++) sum[i]=0;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int T; rd(T);
	while(T--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3388kb

input:

1
4
2 3 4 3

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3512kb

input:

20
43
128 66 452 384 400 441 232 203 228 33 284 156 128 190 197 292 388 31 179 343 147 206 450 284 180 73 273 130 168 250 405 203 235 340 309 28 267 395 152 191 295 463 344
54
48 7 12 37 49 24 5 18 15 37 26 57 53 59 22 10 2 16 36 52 64 1 56 42 38 46 53 7 2 8 60 38 54 11 19 50 20 61 6 50 27 5 26 3 4 ...

output:

9
54
13
7
7
34
47
11
1
102
5
5
37
1
3
7
7
348
14
0

result:

wrong answer 5th numbers differ - expected: '8', found: '7'