Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力
Rock... Paper!
After Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows.
A positive integer n is decided first. Both Koyomi and Karen independently choose n distinct positive integers, denoted by x1, x2, ..., xn and y1, y2, ..., yn respectively. They reveal their sequences, and repeat until all of 2n integers become distinct, which is the only final state to be kept and considered.
Then they count the number of ordered pairs (i, j) (1 ≤ i, j ≤ n) such that the value xi xor yj equals to one of the 2n integers. Here xormeans the bitwise exclusive or operation on two integers, and is denoted by operators ^ and/or xor in most programming languages.
Karen claims a win if the number of such pairs is even, and Koyomi does otherwise. And you're here to help determine the winner of their latest game.
The first line of input contains a positive integer n (1 ≤ n ≤ 2 000) — the length of both sequences.
The second line contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 2·106) — the integers finally chosen by Koyomi.
The third line contains n space-separated integers y1, y2, ..., yn (1 ≤ yi ≤ 2·106) — the integers finally chosen by Karen.
Input guarantees that the given 2n integers are pairwise distinct, that is, no pair (i, j) (1 ≤ i, j ≤ n) exists such that one of the following holds: xi = yj; i ≠ j and xi = xj; i ≠ j and yi = yj.
Output one line — the name of the winner, that is, "Koyomi" or "Karen" (without quotes). Please be aware of the capitalization.
3
1 2 3
4 5 6
Karen
5
2 4 6 8 10
9 7 5 3 1
Karen
In the first example, there are 6 pairs satisfying the constraint: (1, 1), (1, 2), (2, 1), (2, 3), (3, 2) and (3, 3). Thus, Karen wins since 6 is an even number.
In the second example, there are 16 such pairs, and Karen wins again.
题目大意 给定两组数,每组中各选一个数异或得到后的结果在这两组数中出现过的方案数如果是偶数就是Karen赢,否则是Koyomi赢。
暴力for,开个数组去check。完事。
Code
/**
* Codeforces
* Problem#869A
* Accepted
* Time: 280ms
* Memory: 100k
*/
#include <bits/stdc++.h>
using namespace std; int n;
int *x, *y;
set<int> been; inline void init() {
scanf("%d", &n);
x = new int[(n + )];
y = new int[(n + )];
for(int i = ; i <= n; i++)
scanf("%d", x + i), been.insert(x[i]);
for(int i = ; i <= n; i++)
scanf("%d", y + i), been.insert(y[i]);
} int counter = ;
inline void solve() {
for(int i = ; i <= n; i++)
for(int j = ; j <= n; j++)
if(been.count(x[i] ^ y[j])) {
counter++;
}
if(counter & ) puts("Koyomi");
else puts("Karen");
} int main() {
init();
solve();
return ;
}
Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力的更多相关文章
- Codeforces Round #439 (Div. 2) Problem E (Codeforces 869E) - 暴力 - 随机化 - 二维树状数组 - 差分
Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around ...
- Codeforces Round #439 (Div. 2) Problem C (Codeforces 869C) - 组合数学
— This is not playing but duty as allies of justice, Nii-chan! — Not allies but justice itself, Onii ...
- Codeforces Round #439 (Div. 2) Problem B (Codeforces 869B)
Even if the world is full of counterfeits, I still regard it as wonderful. Pile up herbs and incense ...
- Codeforces Round #439 (Div. 2)【A、B、C、E】
Codeforces Round #439 (Div. 2) codeforces 869 A. The Artful Expedient 看不透( #include<cstdio> in ...
- Codeforces Round #716 (Div. 2), problem: (B) AND 0, Sum Big位运算思维
& -- 位运算之一,有0则0 原题链接 Problem - 1514B - Codeforces 题目 Example input 2 2 2 100000 20 output 4 2267 ...
- Codeforces Round #297 (Div. 2)D. Arthur and Walls 暴力搜索
Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec Memory Limit: 512 MBSubmit: xxx ...
- Codeforces Round #753 (Div. 3), problem: (D) Blue-Red Permutation
还是看大佬的题解吧 CFRound#753(Div.3)A-E(后面的今天明天之内补) - 知乎 (zhihu.com) 传送门 Problem - D - Codeforces 题意 n个数字,n ...
- Codeforces Round #771 (Div. 2), problem: (B) Odd Swap Sort
Problem - B - Codeforces 就是给你个序列, 给他整成升序的, 每次操作可以使相邻两个数交换位置, 交换条件是二数之和为奇数 结果只需输出是否可以整成升序的 思路: 需要奇数偶数 ...
- Codeforces Round #306 (Div. 2), problem: (B) Preparing Olympiad【dfs或01枚举】
题意: 给出n个数字,要求在这n个数中选出至少两个数字,使得它们的和在l,r之间,并且最大的与最小的差值要不小于x.n<=15 Problem - 550B - Codeforces 二进制 利 ...
随机推荐
- shell编程:for循环
有几个参数执行几次 do done取代了{} 这种用于 文件的个数,用户的个数等. (())里才可以进行加减乘除.
- Linux MySQL数据库文件同步及数据库备份
Mysql数据库链接 mysql -uroot -p -hdatacenter.jiaofukeyan.com -P33069 1.文件同步 rsync -avz --delete root@(需要同 ...
- jQuery-手风琴伸缩效果
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- 使用sqoop往hdfs中导入数据供hive使用
sqoop import -fs hdfs://x.x.x.x:8020 -jt local --connect "jdbc:oracle:thin:@x.x.x.x:1521:testdb ...
- Hotfix
http://group.jobbole.com/6311/ http://www.jianshu.com/p/6f0ae1e364d9 http://www.mamicode.com/info-de ...
- cache基础
cache是系统中的一块快速SRAM,价格高,但是访问速度快,可以减少CPU到main memory的latency. cache中的术语有: 1) Cache hits,表示可以在cache中,查找 ...
- 10.for
要遍历一个范围(如数组或表),使用 for 循环.在数组上迭代时,当前数组元素存储在循环变量中.在遍历字典时, index 存储在循环变量中. (in 内容测试) for x in [5, 7, 11 ...
- “编程利器”:VSCode
原先一直使用sublime text3,并且认为它是很好的编程利器. 但最近写代码时,发现很多代码还是提示的不够完整.我们知道,当代码名字很长时,还没有提醒,这是非常苦恼的一件事!同时它的调试功能也不 ...
- html5-基本知识小结及补充
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...
- mysql的指令
mysql有一下几方面的特性: 1:多语言支持 2:可以移植性好 3:免费开源 4:高效(支持多线程,充分利用cpu资源,运行速度非常) 5:支持大量数据查询和储存 6:操作简单易于学习 其实数据库就 ...