[ An Ac a Day ^_^ ] Codeforces Round #368 Div. 2 A B C
昨天才回学校 刚好赶上CF所以就没写博客 不过还是水题了……
A.
比赛的时候被hack了 仔细读题才知道grey也算是黑白的
英语不好好伤心……
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#define M(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
int main(){
int n,m;
char cl;
bool ok=true;
scanf("%d%d",&n,&m);
getchar();
for(int i=;i<n;i++){
while(true){
scanf("%c",&cl);
if(cl=='\n') break;
if(cl==' ') continue;
if(cl!='W'&&cl!='B'&&cl!='G') ok=false;
}
}
if(ok) puts("#Black&White");
else puts("#Color");
return ;
}
/* 2 2
C M
Y Y 3 2
W W
W W
B B 1 1
W */
B.
一开始看样例能看出来一点题意……
题意呢……
有两种店 问两种店之间的最短距离
遍历一遍就好了……
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#define M(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
bool bk[];
struct bian{
int start,over,val;
}v[];
int main(){
int n,m,k;
scanf("%d%d%d",&n,&m,&k);
for(int i=;i<m;i++)
scanf("%d%d%d",&v[i].start,&v[i].over,&v[i].val);
for(int i=;i<k;i++){
int a;
scanf("%d",&a);
bk[a]=true;
}
int min_=;
for(int i=;i<m;i++)
if(bk[v[i].start]^bk[v[i].over])
if(v[i].val<min_) min_=v[i].val;
if(min_!=) printf("%d\n",min_);
else printf("-1\n");
return ;
}
/* 5 4 2
1 2 5
1 2 3
2 3 4
1 4 10
1 5 3 1 1
1 2 3
3 */
C.
公式题 给一个数n 问n是不是勾股数 是的话输出另外两个
公式也是上网才搜到……
n==1和n==2时没有勾股数 其他数都有
n是偶数的时候三个数分别是2*n,n*n+1,n*n-1
n是奇数的时候是2*n,2*n*n+2*n,2*n*n+2*n+1
看了下别人的代码 构造很巧妙……
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#define M(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
int main(){
ll n;
scanf("%I64d",&n);
if(n==||n==) printf("-1\n");
else if(n%&&(n/=)) printf("%I64d %I64d\n",*n*n+*n,*n*n+*n+);
else if(n/=)printf("%I64d %I64d\n",n*n-,n*n+);
return ;
}
/* 3 6 1 17 67 */
[ An Ac a Day ^_^ ] Codeforces Round #368 Div. 2 A B C的更多相关文章
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- Codeforces Round #368 (Div. 2) C. Pythagorean Triples(数学)
Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a ...
- Codeforces Round #368 (Div. 2) B. Bakery (模拟)
Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bak ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)
Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...
- Codeforces Round #368 (Div. 2) C
Description Katya studies in a fifth grade. Recently her class studied right triangles and the Pytha ...
- Codeforces Round #368 (Div. 2) B
Description Masha wants to open her own bakery and bake muffins in one of the n cities numbered from ...
- Codeforces Round #368 (Div. 2) A
Description Small, but very brave, mouse Brain was not accepted to summer school of young villains. ...
- Codeforces Round #368 (Div. 2)A B C 水 图 数学
A. Brain's Photos time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Codeforces Round #368 (Div. 2) D. Persistent Bookcase
Persistent Bookcase Problem Description: Recently in school Alina has learned what are the persisten ...
随机推荐
- NGINX----源码阅读---sources配置脚本
/auto/sources 本文件主要用于对源文件环境变量进行初始化,主要包括:.c和.h文件. 对应变量类型有*_MODULES.*_INCS.*_DEPS等. # Copyright (C) Ig ...
- 关于spring autowrie的5种方式
spring自动注入有5中方式,分别是: byName:根据自动注入类中的对象名字,会到配置文件中找相关id或者name的bean,如果找不到则不会匹配,如果找到多个bean,则会报错. byType ...
- 关于float和position
在div 块级元素中,一般我们的div块都是流式的,如果你设定一个div,接下来的div就会另起行,也就是块级元素的定义 但是一般排版不是这样的,最典型的应该就是这种布局了,那么中间的那三个div ...
- hdu 3006 The Number of set
二进制的状态压缩.比如A集合里面有{1,5,7}那么就表示为1010001.B集合有{3,4},二进制表示1100.A|B=1011101. 按照这样的思路 可以用01背包 把所有的组合全部求出来. ...
- Ajax.BeginForm无法调用 ajaxOptions的js函数
使用ajax.beginForm无法调用ajaxOptions的js函数的原因,一般都是缺少以下2个JS文件: 1,Install-Package jQuery –version 1.10.22,In ...
- Chapter 2 Open Book——35
Mr. Banner called the class to order then, and I turned with relief to listen. Banner先生让大家安静听他说,然后我静 ...
- db2 常用配置
db2set配置: db2set DB2_ENABLE_LDAP=NO db2set DB2_ALTERNATE_GROUP_LOOKUP=GETGROUPLIST db2set DB2_RESTOR ...
- seajs +gruntjs 合作开发
nodejs的出现 让服务器端能运行 js commonjs规范 规范服务器端开发按照什么写法去写 包括模块化开发 ( 不同点 请求在本地 js加载) AMD规范 浏览器端开发的规范 (不同点: 浏览 ...
- 修改LibreOffice Draw中定义的样式名称
目前我使用的是LibreOffice 4.2.4.2.经过以往的测试和使用经验,这是诸多版本中较为稳定和bug相对较少的.今天无意中发现该版本的LibreOffice Draw存在一个问题:样式名称修 ...
- 华硕笔记本进pe之前的设置
1.开机的时候长按F2键进入BIOS界面,通过方向键进[Secure]菜单,通过方向键选择[Secure Boot Control]选项,将其设定为 "Disabled"2.通过方 ...