[ 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 ...
随机推荐
- 笔记 bug和任务 工具
云表格 https://www.huoban.com/禅道
- JavaScript忍者秘籍——闭包
概要:本篇博客主要介绍了JavaScript的闭包 1.闭包的工作原理 简单地说,闭包就是一个函数在创建时允许该自身函数访问并操作该自身函数之外的变量时所创建的作用域. 例如: var outerVa ...
- 一个简单sql注入的poc
最近在提高自己编程能力,拿一些实用的小工具练下.该脚本为python语言,主要涉及模块urllib,re. 功能:验证CmsEasy5.5爆账号密码 实验用源码:http://pan.baidu.co ...
- 初级AD域渗透系列
net group /domain 获得所有域用户组列表 net group “domain admins” /domain 获得域管理员列表 net group “enterprise admi ...
- VS2015转VS2008
对于Windows8及以上的系统,无法安装VS2008,也不是无法安装,如果玩游戏多的,应该已经安装了.NET3.5,可以正常安装. 既然不能安装VS2008,那就安装VS2015好了,现在已经是Up ...
- 主机无法访问虚拟机的httpd服务
症状:虚拟机装的centos6.3 通过桥接的方式与主机连接 虚拟机通过yum安装httpd服务 在主机浏览器中输入 虚拟机ip 无法访问虚拟机Apache 虚拟机和主机可以相互ping通 解决:关 ...
- windows composer安装
百度网址 http://jingyan.baidu.com/article/19020a0a39d96e529c284279.html
- Spring.net 学习IOC------准备
在学习spring.net开始时,我们首先要下载spring.net所用到的类库: Common.Logging.dll(必要)Spring.Core.dll(必要)Spring.Data.dllSp ...
- 去掉word冗余格式 java正则表达式
word转换html时,会留下很多格式,有些格式并不是我们所需要的,然而这些格式比真正的文章内容还要多,严重影响页面的加载速度,因此就需要找个一个好的解决方案把这些多余的格式个去掉.网上有很多去除wo ...
- mybatis配置sql超时时间
mybatis如果不配置,默认超时时间是不做限制的.当系统慢sql很多时,势必会增加数据库压力,系统性能及稳定性降低.所以有必要要设置sql超时设置,下面配置超时时间是5分钟. 第一步:全局配置如下 ...