QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#231385#858. GCD vs. XORlnyxWA 1ms3388kbC++141.3kb2023-10-29 10:00:392023-10-29 10:00:39

Judging History

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

  • [2023-10-29 10:00:39]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3388kb
  • [2023-10-29 10:00:39]
  • 提交

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,M=1e6+7;
int n,mx;
int sum[M];
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=1;i<=mx;i++){
			if((i^d)!=i+d) continue;
			// 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;
}

详细

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: 3388kb

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:

41
333
86
33
47
225
369
19
6
678
29
64
396
5
14
30
46
1600
92
0

result:

wrong answer 1st numbers differ - expected: '9', found: '41'