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)的更多相关文章

  1. Codeforces Round #439 (Div. 2)【A、B、C、E】

    Codeforces Round #439 (Div. 2) codeforces 869 A. The Artful Expedient 看不透( #include<cstdio> in ...

  2. Codeforces Round #439 (Div. 2) 题解

    题目链接  Round 439 div2 就做了两道题TAT 开场看C题就不会 然后想了好久才想到. 三种颜色挑出两种算方案数其实是独立的,于是就可以乘起来了. E题想了一会有了思路,然后YY出了一种 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力

    Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-sc ...

  7. 「日常训练」The Intriguing Obsession(CodeForces Round #439 Div.2 C)

    2018年11月30日更新,补充了一些思考. 题意(CodeForces 869C) 三堆点,每堆一种颜色:连接的要求是同色不能相邻或距离必须至少3.问对整个图有几种连接方法,对一个数取模. 解析 要 ...

  8. 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 ...

  9. Codeforces Round #439 (Div. 2) C. The Intriguing Obsession

    C. The Intriguing Obsession 题目链接http://codeforces.com/contest/869/problem/C 解题心得:     1.由于题目中限制了两个相同 ...

随机推荐

  1. Java位运算加密

    创建一个类,通过位运算中的”^"异或运算符把字符串与一个指定的值进行异或运算,从而改变字符串每个字符的值,这样就可以得到一个加密后的字符串.当把加密后的字符串作为程序输入内容,再与那个指定的 ...

  2. Spring事务超时、回滚的相关说明

    事务超时: @Transactional(timeout = 60) 如果用这个注解描述一个方法的话,线程已经跑到方法里面,如果已经过去60秒了还没跑完这个方法并且线程在这个方法中的后面还有涉及到对数 ...

  3. 【云迁移论文笔记】Cloud Migration Research:A Systematic Review

    Cloud Migration Research:A Systematic Review Author Info: Pooyan Jamshidi PhD Postdoctoral Researche ...

  4. delphi 函数参数传递 默认参数(传值)、var(传址)、out(输出)、const(常数)四类

    参数可以分为: 默认参数(传值).var(传址).out(输出).const(常数)四类 {默认参数是传值, 不会被改变} function MyF1(x: Integer): Integer; be ...

  5. 查询sql server 2008所有表和行数

    查询sql server 2008所有表和行数 SELECT a.name, b.rows FROM sysobjects AS a INNER JOIN sysindexes AS b ON a.i ...

  6. 【分享】Linux(Ubuntu)下如何自己编译JDK

    最近在看<深入理解 Java 虚拟机>这本书.里面提到了如何手动编译JDK,于是就试了试. 在编译的过程中,遇到了一些问题.上网一搜,发现了一篇很好的文章,跟大家分享一下:ubuntu 1 ...

  7. Android 请求运行时权限

    写文件到sd卡中,会报权限问题,需要动态申请申请运行时权限 1. MainActivity.java public class MainActivity extends Activity { priv ...

  8. [原]openstack-kilo--issue(一) httpd汇总

    /** 系统环境:redhat7.2 repo:163 openstack version : kilo author: lihaibo **/ 问题1:Invalid command 'group= ...

  9. Windows应急响应操作手册

    查看表征异常 系统卡慢.宕机.CPU和内存占用高.网络拥塞或断网.磁盘空余空间无理由大幅度缩小等,根据以上表征,可以初步猜测系统面临的问题. windows 下查看系统基本信息 PS C:\Users ...

  10. Visual Studio 2012创建SQL Server Database Project提示失败解决方法

    新建一个SQL Server Database Project,提示: Unable to open Database project This version of SQL Server Data ...