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.由于题目中限制了两个相同 ...
随机推荐
- SpringMVC由浅入深day01_3非注解的处理器映射器和适配器
3 非注解的处理器映射器和适配器 3.1 非注解的处理器映射器 3.1.1 HandlerMapping处理器映射器 HandlerMapping 负责根据request请求找到对应的Handler ...
- win10进入到安全模式的三种方法
这里介绍三种方法: 如果能够进入到系统 点击开始--设置--更新和安全--恢复,右侧点击高级启动中的立即重启 能够进入到登陆界面 进入到登录屏幕后,在按住 Shift 键的同时依次选择“电源” > ...
- 【AI】Win10-Tensorflow
一.安装 第一步:先安装anaconda3第二步:pip install --upgrade --ignore-installed tensorflow或者:pip install tensorflo ...
- Spring transaction事务 roll back各种回滚
Spring的AOP事务管理默认是针对unchecked exception回滚. 也就是默认对RuntimeException()异常极其子类进行事务回滚. Exception作为基类,下面还分ch ...
- mybatis 之 parameterType="java.util.List"
<!-- 添加 --> <insert id="saveBatchMemberRoleConnRepModel" parameterType="java ...
- django rest framwork教程之外键关系和超链接
此时,我们的API中的关系通过使用主键来表示.在本教程的这一部分中,我们将通过使用超链接来改善关系的内聚性和可发现性 为我们的API的根创建一个端点 现在我们有"snippets" ...
- 《转》Python学习(17)-python函数基础部分
http://www.cnblogs.com/BeginMan/p/3171977.html 一.什么是函数.方法.过程 推荐阅读:http://www.cnblogs.com/snandy/arch ...
- JSP中使用Spring注入的Bean时需要注意的地方
遇到问题 遇到一个问题:在JSP中,使用Spring注入的Bean对象时,未能正确地获取到想要的对象. 郁闷的是,它也没报错. 研究问题 使用DEBUG功能(好久不在JSP里写Java代码了,都忘了J ...
- jQuery的一些静态方法
// 该方法被绑定在jQuery对象上,只能通过$.noConflict()调用 noConflict: function( deep ) { // 取消$在window上的绑定,方法是将_$绑定到w ...
- create-react-app项目中的eslint
"no-multi-spaces": 1, //禁止多个空格 "jsx-quotes": 1, //此规则强制在JSX属性中一致使用双引号或单引号 " ...