CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution
来源:互联网 发布:电力系统分析知乎 编辑:程序博客网 时间:2024/05/12 01:39
题意: 对于给定的
- 发现数字范围是
[0,100000] ,所以,我们用一个数组cot[300000] ,来记录每个数字i 出现的次数cot[i] ,然后每次加入新的数字x 更新ans+=cot[x⊕m]
#include <cstdio>#include <string>#include<iostream>#include<vector>#include <stack>#include <queue>#include <map>#include <cstdlib>#include<string.h>#include <cstring>#include <ctime>#include <algorithm>#include <set>using namespace std;typedef long long ll;typedef pair<int, int>pii;typedef pair<ll, ll> pll;typedef pair<int, ll> pil;typedef vector<vector<ll> >vvi;typedef vector<ll> vi;const ll mod = 1e9 + 7;const int MAXN = 1000;const int MAXM = 1000;ll pow_mod(ll a, ll n, ll mod){ ll res = 1; while (n) { if (n & 1)res = res*a%mod; a = a*a%mod; n >>= 1; } return res;}ll gcd(ll x, ll y){ return y == 0 ? x : gcd(y, x%y);}ll lcm(ll x, ll y){ return x / gcd(x, y)*y;}struct Edge{ int to; int next; int cal;}edge[MAXM];int head[MAXN], tot;void addedge(int u, int v, int cal){ edge[tot].to = v; edge[tot].cal = cal; edge[tot].next = head[u]; head[u] = tot++;}void init(){ tot = 0; memset(head, -1, sizeof head);}struct Matrix{ int m[10][10]; int n; void E() { for (int i = 0; i < 10; i++)for (int j = 0; j < 10; j++) m[i][j] = i == j; } void clear() { memset(m, 0, sizeof m); } Matrix operator*(const Matrix b) { Matrix res; res.n = b.n; res.clear(); for (int i = 0; i < n; i++)for (int j = 0; j < n; j++) { res.m[i][j] = 0; for (int k = 0; k < n; k++) res.m[i][j] = (res.m[i][j] + m[i][k] * b.m[k][j] % mod) % mod; } return res; } Matrix operator^(ll tim) { Matrix a = *this; Matrix res; res = a; res.E(); while (tim) { if (tim & 1)res = res*a; a = a*a; tim >>= 1; } return res; }};int cot[300000 + 10];int main(){ memset(cot, 0, sizeof cot); int n; int m; scanf("%d%d", &n, &m); ll ans = 0; for (int i = 0; i < n; i++) { int x; scanf("%d", &x); ll plus = m^x; ans += (ll)cot[plus]; cot[x]++; } printf("%I64d\n", ans); //getchar(); //getchar();}
0 0
- Codeforces 742B B. Arpa’s obvious problem and Mehrdad’s terrible solution
- 【codeforces 742B】Arpa’s obvious problem and Mehrdad’s terrible solution
- Codeforces 742B Arpa’s obvious problem and Mehrdad’s terrible solution(map水题)
- Codeforces 742B Arpa’s obvious problem and Mehrdad’s terrible solution
- CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution
- codeforces 742B - Arpa’s obvious problem and Mehrdad’s terrible solution
- CodeForces - 742B Arpa’s obvious problem and Mehrdad’s terrible solution
- Codeforces 742B-Arpa’s obvious problem and Mehrdad’s terrible solution
- 742 B - Arpa’s obvious problem and Mehrdad’s terrible solution codeforces
- Codeforces Round #383 (Div. 2) 742B Arpa’s obvious problem and Mehrdad’s terrible solution
- Codeforces 742 B. Arpa’s obvious problem and Mehrdad’s terrible solution
- Codeforces 742B Arpa’s obvious problem and Mehrdad’s terrible solution
- codeforces 742B Arpa’s obvious problem and Mehrdad’s terrible solution
- CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution
- 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 Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution
- 前端--React之webpack使用教程
- 几个面试基础题
- 使用ViewStub来提高加载性能吧!
- Java高级特性之反射学习总结
- Android Bitmap太大导致ImageView不显示的问题
- CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution
- Vi与Vim的区别
- angular js尝试(二)
- 高质量的代码总结
- FragmentTabHost简单实用
- 错误日志
- C#反射(Reflection)的概念和用法详解
- 有道云笔记发生未知错误,同步不了,及IE浏览器上不网
- 收起展开效果夸张,但不是给用户看的