Codeforces Round #399 (Div. 1 + Div. 2, combined)C. Jon Snow and his Favourite Number
来源:互联网 发布:程序员去汽车厂 编辑:程序博客网 时间:2024/05/18 12:34
因为ai的范围很小,所以可以通过记录每个数的个数来记录这个序列,能想到这样做基本就可以了
然后模拟k次,每次从0开始,一直到1024(因为最大是1000,异或之后可能出现的最大值是1024),根据每个数前面已经出现了几个可以判断这个数第一次出现在按从小到大的排序的序列里是否为第奇数个
例如 1 1 2 2 2 3 3 3
有两个1,并且前面没有任何数,所以这两个1里有一个要异或x,一个不变,三个2,,2前面有两个数,所以第一个2是位于奇数的位置,这三个2里有两个要异或x,一个不变,
三个3,而第一个3是位于偶数的位置,所以三个3里只有一个要异或x
#include<stdio.h>#include<string.h> #include<algorithm>using namespace std;#define MEM(a) memset(a,0,sizeof(a));#define res(i,be,n) for(i=be;i<n;i++)int main(){int n,x,k,a[1030],b[1030],t,i,j,re;scanf("%d %d %d",&n,&k,&x);MEM(a);MEM(b);res(i,0,n){scanf("%d",&j);a[j]++;}res(i,0,k){t=0;res(j,0,1025){b[j]=a[j];}MEM(a);res(j,0,1025){re=(b[j]+!(t&1))/2;a[j^x]+=re;a[j]+=b[j]-re;t+=b[j];}}int maxx=0,minn=1024;res(i,0,1025)if(a[i]){maxx=max(maxx,i);minn=min(minn,i);}printf("%d %d\n",maxx,minn);return 0;}
0 0
- Codeforces Round #399 (Div. 1 + Div. 2, combined)C. 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 768C Jon Snow and his Favourite Number 【思维】
- Codeforces 768C Jon Snow and his Favourite Number【思维】
- CodeForces 768C Jon Snow and his Favourite Number
- C. Jon Snow and his Favourite Number
- Codeforces768C Jon Snow and his Favourite Number
- Codeforces768C-Jon Snow and his Favourite Number
- Jon Snow and his Favourite Number
- codeforces 768 C Jon Snow and his Favourite Number(循环节)
- CodeForces 768C Jon Snow and his Favourite Number 暴力 空间换时间
- Codeforces Round #400 (Div. 1 + Div. 2, combined)B.Sherlock and his girlfriend【预处理素数+思维】
- Codeforces Round #400 (Div. 1 + Div. 2, combined) 776B Sherlock and his girlfriend
- Codeforces Round #400 (Div. 1 + Div. 2, combined) B. Sherlock and his girlfriend 素数筛法+贪心
- Codeforces Round #400 (Div. 1 + Div. 2, combined) C
- [POJ]2739-Sum of Consecutive Prime Numbers
- ural1014 Product of Digits (枚举)
- 最小生成树---->prim算法的应用 hdu1863
- PAT A1056. Mice and Rice (25)
- ubuntu16.04忘记密码处理方法
- Codeforces Round #399 (Div. 1 + Div. 2, combined)C. Jon Snow and his Favourite Number
- 各项知识链接集合(比较杂)
- [HTC Vive + Unity开发]——VRTK的研究——用手柄旋转物体(使用VRTK_Knob脚本)
- TCP/IP 多播和多播路由
- bootstrap折叠调用collapse()后data-parent不生效问题
- csdn上第一篇博客
- 划重点
- 三次握手四次分手
- 数据结构实验:哈希表