Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution(STL乱搞)
来源:互联网 发布:淘宝店铺美工多少钱 编辑:程序博客网 时间:2024/05/22 15:54
题目链接: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代码】
#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<map>#include<queue>#include<stack>using namespace std;#define MOD 10int 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;}
0 0
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution(STL乱搞)
- 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) 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) 742B 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) 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)B.Arpa’s obvious problem and Mehrdad’s terrible solutio【思维】
- codeforces 74B. Arpa’s obvious problem and Mehrdad’s terrible solution (异或+二分STL)
- Arpa’s obvious problem and Mehrdad’s terrible solution CodeForces
- Arpa’s obvious problem and Mehrdad’s terrible solution (CodeForces
- B. Arpa’s obvious problem and Mehrdad’s terrible solution
- Codeforces 742B B. Arpa’s obvious problem and Mehrdad’s terrible solution
- 【codeforces 742B】Arpa’s obvious problem and Mehrdad’s terrible solution
- Ubuntu15安装Redis
- Erlang中的循环
- Java三大特性——继承,封装和多态
- 简单的java实现邮箱发送邮件
- LeetCode-Best Time to Buy and Sell Stock II
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution(STL乱搞)
- Eclipse出现Errors occurred during the build.
- ABBA
- 后台代码
- Linux命令汇总
- 使用JavaMail创建邮件和发送邮件
- 51nod 1405 树的距离之和【树形dp】
- https://www.zhihu.com/question/25427490/answer/30834017
- 隐马尔可夫模型与词性标注(上)