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 二进制 利 ...
随机推荐
- 关于fullpage.js 和animate.css制作全屏简单大方的首页
附上源码: html <!DOCTYPE html><html lang="en"><head> <meta charset=" ...
- C语言记录汇总
uint32_t 转载自:http://blog.sina.com.cn/s/blog_6aea878e0100tl0f.html体会1>. 在写程序时注意"无符号类型&quo ...
- GetLastError()返回值列表
GetLastError()返回值列表: [0]-操作成功完成.[1]-功能错误.[2]-系统找不到指定的文件.[3]-系统找不到指定的路径.[4]-系统无法打开文件.[5]-拒绝访问.[6]-句柄无 ...
- Javascript-双色球
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- Javascript-购物车结算-案例
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- idea创建java的web项目
2. 3. 4. 5. 6. 步骤八: 点击那个倒立的三角形,然后点击Edit Configurations; 步骤八: 步骤九:配置tocat服务器 步骤十:哎,发现,我怎么就只有一个选项呀,art ...
- 扇入Fan-in和扇出Fan-out
什么是扇入和扇出? 在软件设计中,扇入和扇出的概念是指应用程序模块之间的层次调用情况. 按照结构化设计方法,一个应用程序是由多个功能相对独立的模块所组成. 扇入:是指直接调用该模块的上级模块的个数.扇 ...
- highcharts插件
详见官网:https://www.highcharts.com.cn/demo/highcharts 详细使用代码: <!DOCTYPE html> <html lang=" ...
- python 序列化,反序列化
附: pickle 有大量的配置选项和一些棘手的问题.对于最常见的使用场景,你不需要去担心这个,是如果你要在一个重要的程序中使用pickle 去做序列化的话,最好去查阅一下官方文档. https:// ...
- 区块链3.0 ada Cardano卡尔达诺如何获得一致好评?
区块链3.0 ada Cardano卡尔达诺如何获得一致好评? EOS 的直接竞争对手是以太坊.文章介绍的卡尔达诺(Cardano)的目标就更加远大了,他要同时锁定比特币和以太坊.但大家去网上搜索卡尔 ...