A The Artful Expedient
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.

Example
Input
3
1 2 3
4 5 6
Output
Karen
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个不同数的集合 A,B , 对于每对 < i j > ,A[i]^B[i] 的值如果在两个集合中任意一个,则cnt++,如果cnt为奇数输出 Koyomi ,偶数就输出 Karen 。

分析:数据很小,暴力就可以。
一开始用的 map,超时间,改为数组把,又数组越界了,两个在1e6 范围内的数字相异或值肯定是要大于1e6的。开大点就好,就是让1e6的二进制的数位上全变为1,应该就差不多。

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define first fi
#define second se
#define  LL long long
#define fread() freopen("in.txt","r",stdin)
#define fwrite() freopen("out.txt","w",stdout)
#define CLOSE() ios_base::sync_with_stdio(false)const int MAXN = 2e3+10;
const int MAXM = 1e7;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;int arr[MAXN];
int brr[MAXN];
bool vis[MAXM]={0} ;
int main(){CLOSE();
//  fread();
//  fwrite();int n;scanf("%d",&n);for(int i=1;i<=n;i++) {scanf("%d",&arr[i]);vis[arr[i]]=1;}for(int i=1;i<=n;i++) {scanf("%d",&brr[i]);vis[brr[i]] =1;}int cnt=0;for(int i=1;i<=n;i++){for(int j=1;j<=n;j++) {int c=arr[i]^brr[j];if(vis[c]) cnt++;}}if(cnt&1) puts("Koyomi");else puts("Karen");return 0;
}

B The Eternal Immortality

Even if the world is full of counterfeits, I still regard it as wonderful.

Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this.

The phoenix has a rather long lifespan, and reincarnates itself once every a! years. Here a! denotes the factorial of integer a, that is, a! = 1 × 2 × … × a. Specifically, 0! = 1.

Koyomi doesn’t care much about this, but before he gets into another mess with oddities, he is interested in the number of times the phoenix will reincarnate in a timespan of b! years, that is, . Note that when b ≥ a this value is always integer.

As the answer can be quite large, it would be enough for Koyomi just to know the last digit of the answer in decimal representation. And you’re here to provide Koyomi with this knowledge.

Input
The first and only line of input contains two space-separated integers a and b (0 ≤ a ≤ b ≤ 1018).

Output
Output one line containing a single decimal digit — the last digit of the value that interests Koyomi.

Example
Input
2 4
Output
2
Input
0 10
Output
0
Input
107 109
Output
2
Note
In the first example, the last digit of is 2;

In the second example, the last digit of is 0;

In the third example, the last digit of is 2.

分析 :其实只要当便利过程中又0生成我们就可以停止了,之后都会是0,因为此时已经有因子2和5了。
可以想一下,要判断一个数n的阶乘最后一位是不是有零,只要这个数的阶乘结果的分解质因数上有2和5就够了。(一个数n的阶乘含有多少个质因子x ,这个我们可以 用

扯的远了,没有必要,这个题目,我们只要遍历就行,同时这里遍历肯定不会超时,2这个因子过两个数肯定有,而5这个因子过5个数又肯定会有。

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define first fi
#define second se
#define  LL long long
#define fread() freopen("in.txt","r",stdin)
#define fwrite() freopen("out.txt","w",stdout)
#define CLOSE() ios_base::sync_with_stdio(false)const int MAXN = 1e5;
const int MAXM = 1e6;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;int main(){CLOSE();
//  fread();
//  fwrite();LL a,b;cin>>a>>b;if(a==b) {puts("1");return 0;}LL ans=(a+1)%10;for(LL i = a+2;i<=b;i++) {ans=(ans%10*i%10)%10;if(ans==0) break;}printf("%lld\n",ans);return 0;
}

C The Intriguing Obsession
— This is not playing but duty as allies of justice, Nii-chan!

— Not allies but justice itself, Onii-chan!

With hands joined, go everywhere at a speed faster than our thoughts! This time, the Fire Sisters — Karen and Tsukihi — is heading for somewhere they’ve never reached — water-surrounded islands!

There are three clusters of islands, conveniently coloured red, blue and purple. The clusters consist of a, b and c distinct islands respectively.

Bridges have been built between some (possibly all or none) of the islands. A bridge bidirectionally connects two different islands and has length 1. For any two islands of the same colour, either they shouldn’t be reached from each other through bridges, or the shortest distance between them is at least 3, apparently in order to prevent oddities from spreading quickly inside a cluster.

The Fire Sisters are ready for the unknown, but they’d also like to test your courage. And you’re here to figure out the number of different ways to build all bridges under the constraints, and give the answer modulo 998 244 353. Two ways are considered different if a pair of islands exist, such that there’s a bridge between them in one of them, but not in the other.

Input
The first and only line of input contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 5 000) — the number of islands in the red, blue and purple clusters, respectively.

Output
Output one line containing an integer — the number of different ways to build bridges, modulo 998 244 353.

Example
Input
1 1 1
Output
8
Input
1 2 2
Output
63
Input
1 3 5
Output
3264
Input
6 2 9
Output
813023575
Note
In the first example, there are 3 bridges that can possibly be built, and no setup of bridges violates the restrictions. Thus the answer is 23 = 8.

In the second example, the upper two structures in the figure below are instances of valid ones, while the lower two are invalid due to the blue and purple clusters, respectively.


按照自己翻译的做这个题,样例都过不去,真是(菜)。。 最后Google翻译了一下才明白。看懂题目,应该就不难了。
题意 : 有三个集合,每个集合中有如干个点,在满足每个点不会连相同颜色的点的条件下,我们能够连边的情况数目。
分析 : 任意两个集合之间连边的时候是不会影响别的集合,所以我们分开求就行。对于任意两个集合,每个点不能够连相同的颜色,就是相当于一个点只能够和一个点一 一对应,从每个集合中取的个数不同,情况数就不同,用组合数 。

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define first fi
#define second se
#define  LL long long
#define fread() freopen("in.txt","r",stdin)
#define fwrite() freopen("out.txt","w",stdout)
#define CLOSE() ios_base::sync_with_stdio(false)const int MAXN = 5000+10;
const int MAXM = 1e6;
const int mod = 998244353 ;
const int inf = 0x3f3f3f3f;LL fac[MAXN]; // 阶乘
LL C[MAXN+100][MAXN+100]; // 组合数
void init(){fac[0]=1;for(int i=1;i<=MAXN;i++) fac[i]=fac[i-1]*i%mod;for(int i=0;i<=MAXN;i++) C[i][0]=1;for(int i=1;i<=MAXN;i++){for(int j=1;j<=i;j++)C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;}//    for(int i=1;i<=10;i++){//        for(int j=1;j<=i;j++)
//            printf("%d ",C[i][j]);
//        puts("");
//    }
}
LL in[5];
int main(){CLOSE();
//  fread();
//  fwrite();init();cin>>in[1]>>in[2]>>in[3];sort(in+1,in+4);LL ans1=0,ans2=0,ans3=0;for(int i=0;i<=in[1];i++) ans1=ans1%mod+C[in[1]][i]*C[in[2]][i]%mod*fac[i]%mod;for(int i=0;i<=in[1];i++) ans2=ans2%mod+C[in[1]][i]*C[in[3]][i]%mod*fac[i]%mod;for(int i=0;i<=in[2];i++) ans3=ans3%mod+C[in[2]][i]*C[in[3]][i]%mod*fac[i]%mod;printf("%lld\n",ans1*ans2%mod*ans3%mod);return 0;
}

E
E题的题解链接

【CodeForces - 869】 A B C E 【组合数打表】相关推荐

  1. F-子序列(组合数,打表,扩展欧拉,容斥)

    题目链接 题目描述 给出一个长度为n的序列,你需要计算出所有长度为k的子序列中,除最大最小数之外所有数的乘积相乘的结果 输入描述: 第一行一个整数T,表示数据组数. 对于每组数据,第一行两个整数N,k ...

  2. Chosen by god【组合数打表】

    Chosen by god 题目链接(点击) Everyone knows there is a computer game names "hearth stone", recen ...

  3. codeforces 869 E. The Untended Antiquity(树状数组)

    题目链接:http://codeforces.com/contest/869/problem/E 题解:这题是挺好想到solution的但是不太好写,由于题目的特殊要求每个矩形不会重贴所以只要这两个点 ...

  4. Codeforces 869 A.The Artful Expedient(博弈论)

    题解 emmmm 看不懂...英语不行,看大意应该是博弈论 , 我就猜谁在什么情况下会赢,结果是胜者只有一个---Karen #include <bits/stdc++.h> using ...

  5. 【Codeforces 869 C The Intriguing Obsession】 组合数学 思维

    C. The Intriguing Obsession time limit per test1 second memory limit per test256 megabytes inputstan ...

  6. Codeforces 869 C. The Intriguing Obsession (组合数学)

    Description With hands joined, go everywhere at a speed faster than our thoughts! This time, the Fir ...

  7. Chosen by god 【组合数打表,快速幂,求逆元】

    每个人都知道有一个电脑游戏名称"炉石",最近xzz非常喜欢这个游戏.如果你想赢,你需要能力和好运. 有一个咒语名称为"奥术飞弹",可以在所有敌人之间随意分配3种 ...

  8. hdu训练赛 火球术(组合数打表)

    火球术 Time Limit 1s Memory Limit 262144KB Judge Program Standard Ratio(Solve/Submit) 21.43%(3/14) Desc ...

  9. 【Codeforces Round #466】E. Cashback DP+ST表

    题意 给定$n$个数,将其划分成若干个连续的子序列,求最小价值,数组价值定义为,数组和减去$\lfloor \frac{k}{c} \rfloor$,$k$为数组长度,$c$为给定数 可以列得朴素方程 ...

最新文章

  1. Windows中配置java变量环境
  2. 数据结构和算法动态可视化
  3. 代码chaid_[转载]经典决策树之SAS实现--CHAID
  4. qt 中文转十六进制_QT中16进制字符串转汉字
  5. 递归函数合式分解python_零基础学python-18.2 递归函数与分解递归函数的执行步骤
  6. 浅谈C++中内存泄漏的检测
  7. 金电容(法拉电容)与可充放电池的相关知识
  8. 希捷7200.12 固件问题重新上演
  9. 数据库三级模式两级映像
  10. PHP有哪些基本数据类,PHP的基本数据类型
  11. Linux下rar解压工具的安装使用
  12. 悦诗风吟网络营销的目标_“悦诗风吟”品牌的促销策略研究
  13. 计算机水平一般良好怎么填,计算机水平一般怎么填
  14. IOT物联网的九大通信协议
  15. Scrapy爬虫实践之搜索并获取前程无忧职位信息(基础篇)
  16. NETCTOSS代码实现第五版
  17. 快速搭建个人博客——保姆级教程
  18. 新概念英语第三册第一课
  19. 【Python】使用CDS API下载ECMWF气候数据
  20. scratch案例——星星猎手

热门文章

  1. 修改 ubnt 路由器固件
  2. 常用的几个测试网络连接的命令
  3. 不止Alexa和AWS,揭秘亚马逊人工智能发展史
  4. 如何提升网站关键词排名
  5. Linux防火墙放行gre隧道,防火墙 tunnel(GRE隧道)+×××配置过程分析
  6. UR机器人(14)-解决故障
  7. 包含min函数的栈和两个栈实现一个队列
  8. 58. 最后一个单词的长度(水题)
  9. 国产内存真的来了:紫光可提供DDR3、DDR4内存芯片
  10. 国产文件服务器十大品牌,国产服务器十大品牌