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. Eclipse------用Tomcat运行项目后出现:严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener

    Eclipse中Tomcat运行项目后出现: 严重: Error configuring application listener of class org.springframework.web.c ...

  2. Java利用while循环计算1+1/2!+1/3!……+1/20!

    编写程序,用while语句计算1+1/2!+1/3!……+1/20!,并在控制泰山输出计算结果.要求1+1/2!+1/3!……+1/20!,其实就是求1+1*1/2+1*1/2*1/3+……+1*1/ ...

  3. Spring getBean 首字母大小写问题

    如果类第一个字母大写第二个小写,那么首字母小写获取bean 如果第一个和第二个字母都是大写的,那个获取bean首字母要大写

  4. php扩展AMQP,安装报错解决

    接下来来安装php扩展AMQP,安装了它以后,才能用PHP操作rabbitmq.wget https://pecl.php.net/get/amqp-1.4.0.tgztar -zxvf amqp-1 ...

  5. 使用 urllib 发送请求

    urllib.request.urlopen(url, data=None, timeout=n) 用于发送HTTP请求并得到响应内容 In []: import urllib.request In ...

  6. HttpClient 通信工具类

    package com.taotao.web.service; import java.util.ArrayList; import java.util.List; import java.util. ...

  7. Python迭代器笔记

    python中的三大器有迭代器,生成器,装饰器,本文重点讲解下迭代器的概念,使用,自定义迭代器等的介绍. 1.概念: 迭代器是一个对象,一个可以记住遍历位置的对象,迭代器对象从集合的第一个元素开始访问 ...

  8. 【cs229-Lecture4】Newton’s method

    之前我们在求Logistic回归时,用的是梯度上升算法,也就是要使得似然函数最大化,利用梯度上升算法,不断的迭代.这节课引出牛顿方法,它的作用和梯度上升算法的一样的,不同的是牛顿方法所需的迭代次数更少 ...

  9. java基础---->java多线程的使用(十)

    这里介绍一下java中关于线程状态的知识,主要通过代码演示各种状态出现的时机.少年时我们追求激情,成熟后却迷恋平庸,在我们寻找,伤害,背离之后,还能一如既往的相信爱情,这是一种勇气.每个人都有属于自己 ...

  10. html2canvas - 解决办法之图片跨域导致的截图空白

    1. 后端支持:图片要是cdn上的地址,并且允许图片跨域,header头中设置应为 Access-Control-Allow-Origin:  * 2. 前端配置 var opts = { scale ...