Codeforces768C-Jon Snow and his Favourite Number
来源:互联网 发布:淘宝刷客论坛 编辑:程序博客网 时间:2024/06/05 23:45
原题链接
纯暴力,对所有数进行桶排序,d[e][i]表示i这个数的个数,然后对于每种数i算出他在奇数位置上的个数s个,d[e^1][i^x] += s,然后剩余的数不变,d[e^1][i] += d[e][i] - s;
#include <bits/stdc++.h>#define maxn 1000005#define MOD 1000000007using namespace std;typedef long long ll;int d[2][2505];int main(){//freopen("in.txt", "r", stdin); int n, k, x, a;scanf("%d%d%d", &n, &k, &x);for(int i = 0; i < n; i++){scanf("%d", &a);d[0][a]++;}int e = 0;while(k--){int cnt = 0;for(int i = 0; i <= 2500; i++){int s = 0;if(d[e][i]){if(cnt % 2 == 0){s += d[e][i] / 2;if(d[e][i]&1) s++;d[e^1][i^x] += s;}else{s += d[e][i] / 2;d[e^1][i^x] += s;}d[e^1][i] += d[e][i] - s;cnt += d[e][i];d[e][i] = 0;}}e ^= 1;}for(int i = 2500; i >= 0; i--){if(d[e][i]){printf("%d", i);break;}}for(int i = 0; i <= 2500; i++){if(d[e][i]){printf(" %d", i);break;}}puts("");return 0;}
0 0
- Codeforces768C Jon Snow and his Favourite Number
- Codeforces768C-Jon Snow and his Favourite Number
- C. Jon Snow and his Favourite Number
- Jon Snow and his Favourite Number
- Codeforces 768C Jon Snow and his Favourite Number 构造
- Codeforces 768C Jon Snow and his Favourite Number
- 【codeforces 768C】Jon Snow and his Favourite Number
- Codeforces Round #399:C. Jon Snow and his Favourite Number
- codeforces 768C Jon Snow and his Favourite Number 【思维】
- Codeforces 768C Jon Snow and his Favourite Number【思维】
- CodeForces 768C Jon Snow and his Favourite Number
- codeforces 768 C Jon Snow and his Favourite Number(循环节)
- Codeforces Round #399 (Div. 1 + Div. 2, combined)C. Jon Snow and his Favourite Number
- CodeForces 768C Jon Snow and his Favourite Number 暴力 空间换时间
- Jon and Orbs CodeForces
- CodeChef CHSEQ22 Chef and Favourite Sequence
- his first- and
- Jobs And His Apple
- Active-learning 学习(一)——Random-Walker-Based Collaborative learning
- HDU 5907 Find Q
- Zookeeper的Leader选举
- web service开发时,wsdl2java 客户端代码的生成
- CUDA 核函数调用核函数
- Codeforces768C-Jon Snow and his Favourite Number
- Objective-C使用NSFileHandle类对文件进行基本操作,IOS文件操作
- javaWEB总结(23):HttpSession URL重写
- 《JAVA与模式》之门面模式
- Eclipse恢复默认主题及配色;eclipse-color-theme插件安装
- ListView的优化
- windows平台probuf协议socket通信例子
- vue2.0使用Sortable.js实现的拖拽功能
- KMP算法字符串匹配