Codeforces Round #439 (Div. 2)
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必胜。
贴出我暴力的代码:
/* ***********************************************
Author :xiaowuga
Created Time :2017年10月06日 星期五 21时34分51秒
File Name :A.cpp
************************************************ */
#include <bits/stdc++.h>
typedef long long LL;
#define endl "\n"
#define inf 0x3f3f3f3f
const long long N=;
const long long mod=1e9+;
using namespace std;
bool q[*+]={false};
long long a[];
long long b[];
int main(){
ios::sync_with_stdio(false);cin.tie();
int n;
cin>>n;
for(int i=;i<n;i++){
cin>>a[i];
q[a[i]]=true;
}
for(int i=;i<n;i++){
cin>>b[i];
q[b[i]]=true;
}
int ans=;
for(int i=;i<n;i++){
for(int j=;j<n;j++){
int tmp=a[i]^b[j];
if(tmp>*1000000LL) continue;
if(q[tmp]) ans++;
}
}
if(ans&) cout<<"Koyomi"<<endl;
else cout<<"Karen"<<endl;
return ;
}
B. The Eternal Immortality
题目链接:http://codeforces.com/contest/869/problem/B
题目意思:给出两个数a,b其中a<=b,求b!/a!的最后一位是多少?
题目思路:暴力题,首先答案就是(a+1)*(a+2)*(a+3)*(a+4)…………*b,一种思路是暴力直接算,当末尾的的数变成0了以后直接就输出0结束,如果还没有变成0,就循环到b了,直接输出答案,另一种也是暴力算,但是记录一个是否已经含有2和5的这两个质因子(因为一个数包含2和5两个质因子,末尾必定是0)。
代码:
/* ***********************************************
Author :xiaowuga
Created Time :2017年10月06日 星期五 21时53分14秒
File Name :B.cpp
************************************************ */
#include <bits/stdc++.h>
typedef long long LL;
#define endl "\n"
#define inf 0x3f3f3f3f
const long long N=;
const long long mod=1e9+;
using namespace std;
int main(){
ios::sync_with_stdio(false);cin.tie();
long long a,b;
long long sum=;
int c2=,c5=;
cin>>a>>b;
for(long long i=a+;i<=b;i++){
sum*=i%;
sum%=;
if(i%2LL==) c2++;
if(i%5LL==) c5++;
if(c2&&c5) break;
}
if(c2&&c5) cout<<<<endl;
else cout<<sum<<endl;
return ;
}
C. The Intriguing Obsession
题目链接:http://codeforces.com/contest/869/problem/C
题目意思:现在给出红色,蓝色,紫色的点若干,然后现在要在他们之间建桥,相同颜色的点之间不能存在通路,就算存在通路,最小的距离也要大于等于3,问有多少种建桥的方案,答案数mod998244353。
题目思路:相同颜色的点之间不能存在通路,而且最短距离不能小于3,那么我们先考虑其中两种颜色,比如红色和蓝色,那么如果一个红色和两个蓝色之间存在连线,那么就不满足题目的条件,所以我们可以把题目转换为x个不同的小球装入y个不同的箱子,每个箱子最多放一个小球,可以选择不把小球放进箱子,所以公式就是Σ(k=0,min(x,y))C(x,k)*(y!/(y-k)!)或者Σ(k=0,min(x,y))C(y,k)*(x!/(x-k)!)也是可以的,答案是一样的,我们设其为F(x,y),那么最后答案是就是如果三个小球的数量是x,y,z了话,那么最后答案就是F(x,y)*F(x,z)*F(y,z)。
代码:
/* ***********************************************
Author :xiaowuga
Created Time :2017年10月07日 星期六 13时10分37秒
File Name :C.cpp
************************************************ */
#include <bits/stdc++.h>
typedef long long LL;
#define endl "\n"
#define inf 0x3f3f3f3f
const long long N=;
const long long mod=;
using namespace std;
vector<LL>fac,finv;
void init_fav_finv(int n){
fac.resize(n);
finv.resize(n);
fac[]=;
for(int i=;i<n;i++) fac[i]=fac[i-]*i%mod;
finv[]=;
for(int i=;i<n;i++) finv[i]=finv[mod%i]*(mod-mod/i)%mod;
finv[]=;
for(int i=;i<n;i++) finv[i]=finv[i-]*finv[i]%mod;
}
LL Comb(LL n,LL m){
return fac[n]*finv[m]%mod*finv[n-m]%mod;
}
LL Perm(LL n,LL m){
return fac[n]*finv[m]%mod;
}
LL cal(LL x,LL y){
if(x<y) swap(x,y);
LL sum=;
for(LL i=;i<=y;i++){
LL tmp=Comb(y,i)*Perm(x,x-i)%mod;
sum=(sum+tmp)%mod;
}
return sum;
}
int main(){
ios::sync_with_stdio(false);cin.tie();
init_fav_finv();
LL a,b,c;
cin>>a>>b>>c;
cout<<cal(a,b)*cal(a,c)%mod*cal(b,c)%mod<<endl;
return ;
}
Codeforces Round #439 (Div. 2)的更多相关文章
- 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 #439 (Div. 2) 题解
题目链接 Round 439 div2 就做了两道题TAT 开场看C题就不会 然后想了好久才想到. 三种颜色挑出两种算方案数其实是独立的,于是就可以乘起来了. E题想了一会有了思路,然后YY出了一种 ...
- 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) Problem A (Codeforces 869A) - 暴力
Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-sc ...
- 「日常训练」The Intriguing Obsession(CodeForces Round #439 Div.2 C)
2018年11月30日更新,补充了一些思考. 题意(CodeForces 869C) 三堆点,每堆一种颜色:连接的要求是同色不能相邻或距离必须至少3.问对整个图有几种连接方法,对一个数取模. 解析 要 ...
- Codeforces Round #439 (Div. 2) E. The Untended Antiquity
E. The Untended Antiquity 题目链接http://codeforces.com/contest/869/problem/E 解题心得: 1.1,x1,y1,x2,y2 以(x1 ...
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession
C. The Intriguing Obsession 题目链接http://codeforces.com/contest/869/problem/C 解题心得: 1.由于题目中限制了两个相同 ...
随机推荐
- redis make错误处理
cc: ../deps/hiredis/libhiredis.a: No such file or directory cc: ../deps/lua/src/liblua.a: No such fi ...
- 后端判断用户是否关闭浏览器(关闭网站相关的全部tab)
一)程序步骤 1.js 写一个定时请求后端(php),后端接收到请求到,把当前时间戳写入文件 2.php 阻塞,这里我写的是 30 秒,也就是 sleep(30) 3.获取当前时间和文件里的时间作比较 ...
- Java - Calendar类的使用
今天在写代码时需要用到时间相关的类,一开始,数据库中存的数据类型是timestamp的,所以在Java中就使用了 Timestamp类型,但当调用Timestamp类型的方法时发现,它的很多方法都是d ...
- linux 下的爆破工具hydra
http://www.cnblogs.com/mchina/archive/2013/01/01/2840815.html 安装手册 http://www.aldeid.com/wiki/Thc-hy ...
- Memcached 命令行操作
telnet 用于连接 Memcached: [root@localhost ~]# telnet Trying 127.0.0.1... Connected to 127.0.0.1. Escape ...
- Splash 对象方法
go() wait() jsfunc() evaljs() runjs() autoload() call_later() http_get() http_post() set_content() h ...
- 在 Linux 使用 GCC 编译C语言共享库
对任何程序员来说库都是必不可少的.所谓的库是指已经编译好的供你使用的代码.它们常常提供一些通用功能,例如链表和二叉树可以用来保存任何数据,或者是一个特定的功能例如一个数据库服务器的接口,就像MySQL ...
- Windows下POSIX线程编程(pThread)环境搭建
系统: Windows 编辑器:codeblocks13.12 1. 简介: Windows有一个叫 POSIX Threads for Win32 的开源项目给出了一个功能比较完善的Windows下 ...
- vue里面引入jq的方法
1:因为已经安装了vue脚手架,所以需要在webpack中全局引入jquery 打开package.json文件,在里面加入这行代码,jquery后面的是版本,根据你自己需求更改. dependenc ...
- UITableView-FDTemplateLayoutCell 学习笔记
本文转载至 http://www.tuicool.com/articles/I7ji2uM 原文 http://everettjf.github.io/2016/03/24/learn-uitabl ...