A. The Artful Expedient

Problem Statement

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 xor means 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.

Input

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

Output one line — the name of the winner, that is, “Koyomi” or “Karen” (without quotes). Please be aware of the capitalization.

Examples

Example 1
    Input
        3
        1 2 3
        4 5 6
    Output
        Karen
Example 2
    Input
        5
        2 4 6 8 10
        9 7 5 3 1
    Output
        Karen

Note

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.

题意

有两个人在玩游戏,每个人有一段长为n的序列,且这2*n个数全都不同。问你其中有几对数对满足从第一段序列中选出一个数和第二段序列中选出一个数,他们的异或和在这2*n个数中存在。如果有偶数对,那么Karen赢,否则Koyomi赢。

思路

最暴力的方法,当然是直接n^2*log(n)暴力扫然后用set存这2n个数啦;
    其实还有另一种解法,因为如果ai xor bj = aka_i\ xor\ b_j\ =\ a_k,那么ak xor bj = aia_k\ xor\ b_j\ =\ a_i。所以肯定都是偶数对偶数对出现的,只要直接puts(“Karen”);就行啦!

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline void readInt(int &x) {x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;
}
inline void readLong(ll &x) {x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;
}
/*================Header Template==============*/
int a[2005],n,x[2005],ans=0;
set<int> sa,sb;
int main() {readInt(n);for(int i=1;i<=n;i++)readInt(a[i]),sa.insert(a[i]);for(int i=1;i<=n;i++)readInt(x[i]),sb.insert(x[i]);for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(sa.count(a[i]^x[j])||sb.count(a[i]^x[j]))ans++;
//  cout<<ans<<endl;if(ans&1)puts("Koyomi");elseputs("Karen");return 0;
}

Another Code

#include<cstdio>
main(){puts("Karen");}

在PHP语言里,只需要5B代码:Karen,你就能A掉此题啦!

Codeforces Round #439 (Div. 2) A. The Artful Expedient相关推荐

  1. 【Codeforces Round #439 (Div. 2) A】The Artful Expedient

    [链接] 链接 [题意] [题解] 暴力 [错的次数] 在这里输入错的次数 [反思] 在这里输入反思 [代码] #include <bits/stdc++.h> using namespa ...

  2. Codeforces Round #439 (Div. 2) E. The Untended Antiquity 二维线段树||二维树状数组

    http://codeforces.com/contest/869/problem/E 题意:n*m的矩阵,q次操作,三种类型 类型1:给指定矩阵加上围栏 类型2:给指定矩阵去掉围栏 类型3:查询两点 ...

  3. 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 ...

  4. Codeforces Round #439 (Div. 2)

    一句话题意: A:传送门 题意:给定两个长为\(n\)的数组\(a\),\(b\),令\(ans=\)有序对\((i,j)\)的个数使得\(a_i\ xor\ b_j\)在这\(2n\)个数中出现过, ...

  5. Codeforces Round #439 (Div. 2)C - The Intriguing Obsession(简单dp)

    传送门 题意 给出三个集合,每个集合的元素数量为a,b,c,现在需要连边,满足集合内元素不可达或最短路为3,求可行方案数 分析 设dp[i][j]为a集合元素为i个,b集合元素为j个的可行方案,易知( ...

  6. Codeforces Round #439 (Div. 2) E. The Untended Antiquity (hash+数状数组)

    这个题,做出来的人很多,我感觉是数据不够强,我看了很多人的代码直接暴力也能过了,直接暴力如果数据够强的话肯定是时间超限,边缘数据不够强.如果和上次一样估计很多人的E会GG.我看到一位OIdalao的代 ...

  7. Codeforces Round #439 (Div. 2) E. The Untended Antiquity(二维BIT)

    题意:在 n×m 的二维图上,有三种操作: 1 r1 c1 r2 c2 表示沿着 (r1, c1, r2, c2) 所表示的矩形的外边框建围墙.(其中 (r1, c1) 为矩形左上角,(r2, c2) ...

  8. Codeforces Round #439 (Div. 2) E. The Untended Antiquity

    E. The Untended Antiquity Problem Statement Adieu l'ami.     Koyomi is helping Oshino, an acquaintan ...

  9. Codeforces Round #439 (Div. 2) C.The Intriguing Obsession(组合数、记忆化搜索)

    题意: 给出a个红色点,b个蓝色点,c个紫色点,我们可以在这些点之间连任意数量长度为1的边,但是限制同颜色的点之间不能连边且同颜色的点之间的最短路径至少为3,求方案数% 998244353, a,b, ...

最新文章

  1. 第二十七讲 微分方程组解的图像
  2. matlab方位探测处理,急大神帮忙,谁有MATLAB解算像片内外方位元素的程序
  3. 直播报名 | 教你从 0 到 1 打造数字化运营闭环
  4. C++11学习笔记-----线程库std::thread
  5. java常用类总结_java——常用类的总结
  6. 计算机应用综合实践实验心得,综合实践活动培训心得体会范文(精选5篇)
  7. FreeEIM 2013 SDK 部分源码
  8. Logback MDC
  9. python文件处理——JSON格式文件
  10. 转载--认识迅雷界面引擎
  11. docker安装FastDFS
  12. 存储区域网络(SAN)概念和设计基础
  13. jquery Chosen使用
  14. CSS制作各种三角形写法
  15. Java Resources是什么
  16. 熬夜整理,五万字长文总结 C/C++ 知识点
  17. 教你怎么学习Java
  18. 获取搜狗音乐的真实路径方法
  19. 编写一个程序从键盘输入字符,并按要求输出
  20. vue的两种路由模式原理

热门文章

  1. flyway版本号_使用flyway作为数据库版本工具
  2. 本轮大宗商品涨价:(背后原因分析)2021-09
  3. STM32F103学习之系统时钟配置
  4. ctfshow sql注入 web171-web253 wp
  5. nefu 1116 字符串加密
  6. sin30的c语言表达式,c语言sin30怎么写
  7. 医疗his系统值不值得投入使用
  8. Docker部署免安装版tomcat+mysql+其它乱七八糟软件(包含解释为什么这样安装及同理安装的其他方式)
  9. 使用exe4j+inno setup打包exe文件踩坑记录
  10. c语言负数与正数判断大小,c语言编程,输入一些整数,判断其中正数与负数的个数,并分别求出正数与负数的平均值...