CodeForces - 742B Arpa’s obvious problem and Mehrdad’s terrible solution
Posted 啦啦啦天啦噜
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeForces - 742B Arpa’s obvious problem and Mehrdad’s terrible solution相关的知识,希望对你有一定的参考价值。
假期训练的一道题,用了一些异或的一些性质1^2=3,3^1=2,3^2=1
就是相当于反向异或运算然后查找个数。
提供一组样例
5 0
1 1 1 1 1
这就是用long long的原因
下面是代码
1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1e6+5; 4 typedef long long ll; 5 int b[maxn], n, x; 6 7 int main() 8 { 9 while(~scanf("%d %d",&n,&x)) 10 { 11 memset(b, 0, sizeof(b)); 12 ll ans = 0; 13 for(int i = 1; i <= n; i++) 14 { 15 int a; 16 scanf("%d", &a); 17 ans += b[a^x]; 18 b[a]++; 19 } 20 printf("%lld\n", ans); 21 } 22 return 0; 23 }
以上是关于CodeForces - 742B Arpa’s obvious problem and Mehrdad’s terrible solution的主要内容,如果未能解决你的问题,请参考以下文章
Arpa's weak amphitheater and Mehrdad's valuable Hoses CodeForces - 742D
Codeforces 741B Arpa's weak amphitheater and Mehrdad's valuable Hoses
CodeForces 742A Arpa’s hard exam and Mehrdad’s naive cheat
Arpa’s hard exam and Mehrdad’s naive cheat CodeForces - 742A (大水题)
codeforces 741D Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths
Codeforces 741 D - Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths