Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution(STL乱搞)
2017-03-01 19:23
435 查看
题目链接:http://codeforces.com/contest/742/problem/B
【中文题意】给你一个含有n个数的序列和一个整数x,问你在这个序列中能找到多少组a[i]^a[j]=x。(i<=j)
【思路分析】直接用Map搞一下就好了,首先你想,a[i]^a[j]=x;那么a[i]^x=a[j],a[j]^x=a[i]都是成立的,所以直接用map记录一下数,然后求map[a[j]^x]的个数就好了,注意一点,组数可能会超过int。
【AC代码】
【中文题意】给你一个含有n个数的序列和一个整数x,问你在这个序列中能找到多少组a[i]^a[j]=x。(i<=j)
【思路分析】直接用Map搞一下就好了,首先你想,a[i]^a[j]=x;那么a[i]^x=a[j],a[j]^x=a[i]都是成立的,所以直接用map记录一下数,然后求map[a[j]^x]的个数就好了,注意一点,组数可能会超过int。
【AC代码】
#include<cstdio> #include<cstring> #include<string> #include<cmath> #include<map> #include<queue> #include<stack> using namespace std; #define MOD 10 int a[100005],x,n; int main() { while(~scanf("%d %d",&n,&x)) { long long int re=0; map<int,int> m; for(int i=1;i<=n;i++) { scanf("%d",&a[i]); re+=m[a[i]^x]; m[a[i]]++; } printf("%lld\n",re); } return 0; }
相关文章推荐
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution 数学
- Arpa’s obvious problem and Mehrdad’s terrible solution CodeForces - 742B (异或)
- 742 B - Arpa’s obvious problem and Mehrdad’s terrible solution codeforces
- Codeforces Round #383 (Div. 2)C. Arpa's loud Owf and Mehrdad's evil plan(dfs&lcm)
- B. Arpa’s obvious problem and Mehrdad’s terrible solution #383 B
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution
- Codeforces Round #383 (Div. 2) A.Arpa’s hard exam and Mehrdad’s naive cheat【循环节/快速幂】
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution(模拟)
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution
- Codeforces Round #383 (Div. 2) Arpa’s obvious problem and Mehrdad’s terrible solution 数学
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution —— 异或
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution 数论、易错
- Codeforces Round #383 (Div. 2)-C. Arpa's loud Owf and Mehrdad's evil plan
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution
- Codeforces Round #383 (Div. 2) A. Arpa’s hard exam and Mehrdad’s naive cheat(快速幂水题)
- codeforces 742B - Arpa’s obvious problem and Mehrdad’s terrible solution
- CF 742 B-Arpa’s obvious problem and Mehrdad’s terrible solution
- Codeforces Round #383 (Div. 2)B.Arpa’s obvious problem and Mehrdad’s terrible solutio【思维】