A. The Artful Expedient

题目链接:http://codeforces.com/contest/869/problem/A

题目意思:给你两个数列,各包含n个数,现在让你从上下两个数列中各取一个数a[i],b[j],如果a[i]^b[j]在这2×n个数里面出现过,那么就获得一分,问将任意的a[i],b[j]之间的亦或之后,如果分数是奇数则Koyomi胜利,否则Karen胜利。问最后到底谁胜了。

题目思路:非常无聊的题目,暴力都可以过,就是暴力枚举a[i],b[j],把所有答案都算出来,然后再用一个判定存在的数组,来判定是否出现过,然后算出最后的分数,但是有一个坑点.a[i]^a[j]可能会爆2*10^6所以当答案超出这个值的时候可以直接continue,或者你开4*10^6也是没有问题的,比赛的时候我是这么做的,但是实际上并不需要这么做,因为假设存在a[i]^b[j]==x存在于这2*n个数之中,那么x^a[i]=b[j](x与b[j]一组)或者x^b[j]=a[i](x与a[i]一组),所以存在一组就不定存在另一组与之对应,所以必定存在偶数组,所以karen必胜。

贴出我暴力的代码:

 1 /* ***********************************************
 2 Author        :xiaowuga
 3 Created Time  :2017年10月06日 星期五 21时34分51秒
 4 File Name     :A.cpp
 5 ************************************************ */
 6 #include <bits/stdc++.h>
 7 typedef long long LL; 
 8 #define endl "\n" 
 9 #define inf 0x3f3f3f3f 
10 const long long N=1000000;
11 const long long mod=1e9+7;
12 using namespace std;
13 bool q[2*1000000+10]={false};
14 long long a[2000];
15 long long b[2000];
16 int main(){
17     ios::sync_with_stdio(false);cin.tie(0);
18     int n;
19     cin>>n;
20     for(int i=0;i<n;i++){
21         cin>>a[i];
22         q[a[i]]=true;
23     }
24     for(int i=0;i<n;i++){
25         cin>>b[i];
26         q[b[i]]=true;
27     }
28     int ans=0;
29     for(int i=0;i<n;i++){
30         for(int j=0;j<n;j++){
31             int tmp=a[i]^b[j];
32             if(tmp>2*1000000LL) continue;
33             if(q[tmp]) ans++;
34         }    
35     }
36     if(ans&1) cout<<"Koyomi"<<endl;
37     else cout<<"Karen"<<endl;
38     return 0;
39 }
View Code

相关文章:

  • 2021-09-26
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2021-08-12
  • 2021-04-24
猜你喜欢
  • 2022-12-23
  • 2021-06-11
  • 2021-08-28
相关资源
相似解决方案