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 ...
随机推荐
- c++ c# java 调用 c++ 写的dll
1. vs 中新建win32 dll 项目 testdll 添加实现文件 test.cpp #include "stdafx.h" #include <ios ...
- 关于checkbox复选框
1.复选框后面为什么会有间距,如图 首先这肯定不是空格.实际上是这样的,在Firefox,chrome,Safari等现代浏览器下复选框与文字的间隔确实是由margin引起的,也就是默认情况下,che ...
- IOS系列swift语言之课时七
这下需要掌握的就是类型转换,类的构造器,判断类型,异常,异常的处理,defer,范型,约束加速刷代码 import Foundation /* 类型转换 1.利用类的构造器进行转换 2.系统可能提供一 ...
- npm install socket.io遇到的问题
解决方法: 输入 npm install socket.io 前,先执行下面 npm config set proxy "http://yourip:port" 生产的npm-de ...
- 使用git从服务器下载已存在的项目文件
在项目所在路径下输入: git remote -v 获得项目在服务器下的路径如下: origin ssh://git@ygl-redis:300/home/git/perfectunits-iphon ...
- VisualRust + VisualGDB编辑调试Rust
Rust到1.6了,到了一个相对成熟的阶段,可以试用做一些项目了.但是写的代码越多,就会发现一个好的IDE相当于效率的一半.这里分享我 在Visual Studio的使用Rust的经验. 首先需要下载 ...
- spring mvc 第四天【注解实现springmvc 配合使用Exception Resolver 的配置】
Tips:这里使用具体springmvc的异常处理只是拿一个简单的案例来说明问题,并不做实用,如有需求可做更改: 这里演示的仅是能够实现service验证的一种方案,如有更好的请留言我会努力学习!! ...
- java环境基础步骤 jdk tomcat eclipse
1.下载jdk,安装jdk 2.设置环境变量 1)打开我的电脑--属性--高级--环境变量 2)系统变量→新建 JAVA_HOME 变量 变量值填写jdk的安装目录(本人是 D:\java\jdk1. ...
- 调用JavaScript
当webdriver 遇到没法完成的操作时,笔者可以考虑借用JavaScript 来完成,比下下面的例子,通过JavaScript 来隐藏页面上的元素.除了完成webdriver 无法完成的操作,如果 ...
- WEB中的GET和POST
客户端提交数据到服务器端有两种方式GET和POST,get是将数据拼接到url上,而post是将数据封装在request body中,发送过去.顾名思义,get即请求数据,有时需要其附带部分参数:po ...