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 ...
随机推荐
- sublime中侧边栏字体大小的设置
sublime这个编辑器相当强大,但是它的侧边栏字体实在是太小了,实在是反人类的设计,幸好它给了我们修改的机会 第一步:下载PackageResourceViewer插件,通过PackageContr ...
- 一个简单xml数据转换为数组的方法
本人用easywechat做微信回复图文,从数据库中拿到的数据直接是xml拼好的数据,但是框架只有自带的获取xml格式的语句,所有需要将xml数据中所需要的数据拿出来用来拼接. 搜了好多资料说的都很麻 ...
- Spring MVC @Transactional注解方式事务失效的解决办法
在springMVC类上绑定@Transactional的注解,但是访问数据库时,总是报 can't localtion to current JTA Transactional. 后来发现sprin ...
- iOS8 定位补充
iOS 8定位补充 iOS 8定位需要修改2个地方 1.info.plist文件中添加NSLocationAlwaysUsageDescription:描述信息 从iOS 8开始,用户定位分两种情况 ...
- JavaScript语法结构
一:字符集 1.区分大小写 JavaScript是区分大小写的语言 所有的标识符(identifier)都必须采取一致的大小写形式 但是Html并不区分大小写(尽管Xhtml区分) 2.空格.换行符和 ...
- tomcat(三)--基本安装配置
0x01 JDK和Tomcat安装 到oracle官网下载jdk,当前下载的版本是Linux x64 jdk-8u101-linux-x64.tar.gz 到apache官网下载tomcat,当前最 ...
- H5学习系列之Geolocation API
获取位置信息途径: 1.IP地址地理定位数据 2.GPS地理定位数据 3.WI-FI地理定位数据 4.手机地理定位数据 无废话直接上重点:navigator.geolocation对象就是获取地理位置 ...
- WinForm开发之取送货管理2
写的有点慢,但都是一步步操作的,希望这些能成为以后宝贵的财富,话不多说,续上次取送货基本信息管理之产品分类管理,下面进行增删改的编写. 增加产品分类管理信息记录,双击[新增]按钮(其新增可让用户在Te ...
- MVC 之 WebAPI 系列一
1. Web API简单说明 近来很多大型的平台都公开了Web API.比如百度地图 Web API,做过地图相关的人都熟悉.公开服务这种方式可以使它易于与各种各样的设备和客户端平台集成功能,以及通过 ...
- .net多线程
线程 线程池 异步 异步更新winform界面 线程同步