CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution (暴力枚举)
题意:求定 n 个数,求有多少对数满足,ai^bi = x。
析:暴力枚举就行,n的复杂度。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
const int dr[] = {-1, 1, 0, 0};
const int dc[] = {0, 0, 1, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
int a[100005];
int b[100005]; int main(){
LL n, m;
while(scanf("%I64d %I64d", &n, &m) == 2){
for(int i = 0; i < n; ++i) scanf("%d", a+i);
memset(b, 0, sizeof b);
LL ans = 0;
// if(m == 0){
// for()
// continue;
// }
for(int i = n-1; i >= 0; --i){
LL t = a[i] ^ m;
if(t < 100005) ans += b[t];
++b[a[i]];
}
cout << ans << endl;
}
return 0;
}
CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution (暴力枚举)的更多相关文章
- 枚举 || CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution
给出N*M矩阵,对于该矩阵有两种操作: 1.交换两列,对于整个矩阵只能操作一次 2.每行交换两个数. 交换后是否可以使每行都递增. *解法:N与M均为20,直接枚举所有可能的交换结果,进行判断 每次枚 ...
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution —— 异或
题目链接:http://codeforces.com/contest/742/problem/B B. Arpa's obvious problem and Mehrdad's terrible so ...
- Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution
B. Arpa’s obvious problem and Mehrdad’s terrible solution time limit per test 1 second memory limit ...
- 【codeforces 742B】Arpa’s obvious problem and Mehrdad’s terrible solution
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Arpa’s obvious problem and Mehrdad’s terrible solution 思维
There are some beautiful girls in Arpa’s land as mentioned before. Once Arpa came up with an obvious ...
- B. Arpa’s obvious problem and Mehrdad’s terrible solution
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- CF742B Arpa's obvious problem and Mehrdad's terrible solution 题解
Content 有一个长度为 \(n\) 的数组,请求出使得 \(a_i \oplus a_j=x\) 且 \(i\neq j\) 的数对 \((i,j)\) 的个数.其中 \(\oplus\) 表示 ...
- codeforces 741D Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths(启发式合并)
codeforces 741D Arpa's letter-marked tree and Mehrdad's Dokhtar-kosh paths 题意 给出一棵树,每条边上有一个字符,字符集大小只 ...
- codeforces 741D Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths
题目链接:Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths 第一次写\(dsu\ on\ tree\),来记录一下 \(dsu\ o ...
随机推荐
- <一>Angular.js学习
angular.module(name, [a], [b]); // angular.module()创建.获取.注册angular中的模块 name:字符串类型,代表模块的名称: a:字符串的数组 ...
- ubuntu 安装mysql-python和 python-ldap,navicate 问题
1.Ubuntu 下 pip install mysql-python 报错 EnvironmentError: mysql_config not found 原因是缺少mysqlclient 包,执 ...
- [转]保护眼睛的Windows和IE、Firefox、谷歌等浏览器颜色设置
保护眼睛的Windows和IE.Firefox.谷歌等浏览器颜色设置 长时间在电脑前工作,窗口和网页上的白色十分刺眼,眼睛很容易疲劳,也容易引起头痛,其实我们可以通过设置Windows窗口和软件的颜 ...
- 关于$.fn.*的使用
这个案例是我封装了一个树形插件,也是别人写好的,但是对于我来说调用起来不是很方便,就对他的初始化方法又进行了一次封装,总的来说显得比较麻烦,不过我是新手嘛 DEMO 封装一个jcTree的方法$.fn ...
- POJ2553
题意:很难懂!但是大体意思就是求有向图中从一个节点出发到达的点也能反向到达该节点的点.如a能到{b1,b2.....bx}这些点,而这些点也能到a,则a为要求的点.题目是求出所有的这种点. 对图进行缩 ...
- 绘制相切弧arcTo
绘制相切弧 语法: CanvasRenderingContext2D.arcTo( x1, y1, x2, y2, radius ) 描述: 该方法用于绘制圆弧 绘制的规则是当前位置与第一个参考点连线 ...
- (转)在MAC上查找和设置$JAVA_HOME
最近升级了MAC OS,装了JDK7 for mac,在这里下载JDK7 for mac,装完之后发现在默认的路径下找不到JDK7的HOME,如下所示: $ which java /usr/bin/j ...
- x-requested-with 请求头 区分ajax请求还是普通请求(转)
在服务器端判断request来自Ajax请求(异步)还是传统请求(同步): 两种请求在请求的Header不同,Ajax 异步请求比传统的同步请求多了一个头参数 1.传统同步请求参数 accept t ...
- 网站微信登录授权 ASP.NET
最新做一些项目都有微信登录注册什么的,今天就把自己整理的demo提供给大家 微信认证流程(我自己简称三次握手): 1.用户同意授权,获取code 2.通过code换取网页授权access_token, ...
- 编写serversocket简单示例1
package j2se.core.net.tcp; import java.io.DataOutputStream;import java.io.IOException;import java.ne ...