codeforces 869A The Artful Expedient【暴力枚举/亦或性质】
A.
1 second
256 megabytes
standard input
standard output
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 andy1, 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.
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.
【题意】:判断a[i]^b[j]==a或b中的一个的pair数量的奇偶 。
【分析】:枚举/亦或性质永远是Karen win
【代码】:
#include <bits/stdc++.h> using namespace std;
int mp[*];
int a[],b[]; int main()
{
int n;
cin>>n;
for(int i=;i<=n;i++)
{
cin>>a[i];
mp[ a[i] ]=;
}
for(int i=;i<=n;i++)
{
cin>>b[i];
mp[ b[i] ]=;
}
int cnt=;
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
if( mp[ a[i]^b[j] ] )
cnt++;
}
}
if(cnt&) cout<<"Koyomi"<<endl;
else cout<<"Karen"<<endl;
return ;
}
暴力
#include <bits/stdc++.h> using namespace std; int main()
{
cout<<"Karen"<<endl;
return ;
}
magic
codeforces 869A The Artful Expedient【暴力枚举/亦或性质】的更多相关文章
- CodeForces - 869A The Artful Expedient
		题意:有两个序列X和Y,各含n个数,这2n个数互不相同,若满足xi^yj的结果在序列X内或序列Y内的(xi,yj)对数为偶数,则输出"Karen",否则输出"Koyomi ... 
- D. Diverse Garland  Codeforces Round #535 (Div. 3)  暴力枚举+贪心
		D. Diverse Garland time limit per test 1 second memory limit per test 256 megabytes input standard i ... 
- Codeforces 626D Jerry's Protest(暴力枚举+概率)
		D. Jerry's Protest time limit per test:2 seconds memory limit per test:256 megabytes input:standard ... 
- codeforces 675B B. Restoring Painting(暴力枚举)
		题目链接: B. Restoring Painting time limit per test 1 second memory limit per test 256 megabytes input s ... 
- CodeForces - 593A -2Char(思维+暴力枚举)
		Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is th ... 
- Codeforces Round #349 (Div. 1)  B. World Tour 最短路+暴力枚举
		题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一 ... 
- Codeforces Round #298 (Div. 2) B. Covered Path 物理题/暴力枚举
		B. Covered Path Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/probl ... 
- Codeforces Round #439 (Div. 2) A. The Artful Expedient
		A. The Artful Expedient 题目链接http://codeforces.com/contest/869/problem/A 解题心得:就是一个水题,读懂题就好,题意是,(i,j)a ... 
- Codeforces 425A Sereja and Swaps(暴力枚举)
		题目链接:A. Sereja and Swaps 题意:给定一个序列,能够交换k次,问交换完后的子序列最大值的最大值是多少 思路:暴力枚举每一个区间,然后每一个区间[l,r]之内的值先存在优先队列内, ... 
随机推荐
- 正式进军Matlab图像处理
			Matlab取整函数有:fix, floor, ceil, round,具体应用方法如下: 1. fix朝零方向取整,如fix(-1.3) = -1; fix(1.3) = 1; 2. floor顾名 ... 
- [CF1019A]Elections
			题目大意:有$n$个人,$m$个政党,每个人都想投一个政党,但可以用一定的钱让他选你想让他选的政党. 现在要$1$号政党获胜,获胜的条件是:票数严格大于其他所有政党.求最小代价 题解:暴力枚举其他政党 ... 
- 【NOIP模拟赛】飞(fly) 数论+树状数组
			树状数组一个被发明以来广为流行的数据结构,基于数组,核心是lowerbit()操作.他向前lowerbit()操作为前缀,向后lowerbit()操作为上辖,我们运用树状数组都是使一个由O(1)变为O ... 
- poj  1523  割点 tarjan
			Description Consider the two networks shown below. Assuming that data moves around these networks on ... 
- BigDecimal精度问题
			介绍 1.商业计算使用BigDecimal. 2.使用参数为String的构造函数. 3.BigDecimal都是不可变的,每一步的运算时,都会产生一个新的对象.所以在做加减乘除后千万要保存操作后的值 ... 
- Bzoj3441 乌鸦喝水
			Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 258 Solved: 97 Description [题目背景] 一只乌鸦在自娱自乐,它在面 ... 
- 51nod 1060 最复杂的数
			把一个数的约数个数定义为该数的复杂程度,给出一个n,求1-n中复杂程度最高的那个数. 例如:12的约数为:1 2 3 4 6 12,共6个数,所以12的复杂程度是6.如果有多个数复杂度相等,输出最 ... 
- 洛谷 PT2 First Step (ファーストステップ)
			题目背景 知らないことばかりなにもかもが(どうしたらいいの?) 一切的一切 尽是充满了未知数(该如何是好) それでも期待で足が軽いよ(ジャンプだ!) 但我仍因满怀期待而步伐轻盈(起跳吧!) 温度差なん ... 
- USACO_1.1_Your_Ride_Is_Here_(字符串+水题)
			描述 http://train.usaco.org/usacoprob2?a=y0SKxY0Kc2q&S=ride 给出两个由大写字母组成,长度不大于$6$的字符串. 将字符串中的各字母的字典 ... 
- [BZOJ2946] [Poi2000]公共串解题报告|后缀数组
			给出几个由小写字母构成的单词,求它们最长的公共子串的长度. 单词个数<=5,每个单词长度<=2000 尽管最近在学的是SAM...但是看到这个题还是忍不住想写SA... (其实是不 ... 
