[ 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 ...
随机推荐
- windows 上搭建 sftp 服务器 --freesshd
Linux 下 sftp 默认都会安装的, Windows 就没有了.网上搜的资料发现比较好用的是 freesshd,免费版中最好用的. 1,下载:http://www.freesshd.com/?c ...
- python3.5 修改 IIS WEB.CONFIG的相关方法
#!/usr/bin/env python3.5 # -*- coding:utf8 -*- from xml.etree.ElementTree import ElementTree,Element ...
- python 访问数据库
commit() 提交rollback() 回滚 cursor用来执行命令的方法:callproc(self, procname, args):用来执行存储过程,接收的参数为存储过程名和参数列表,返回 ...
- centos设置svn开机自启动
安装好 svn 服务后,默认是没有随系统启动自动启动的, CentOS 7 的 /etc/rc.d/rc.local 是没有执行权限的, 系统建议创建 systemd service 启动服务 于是查 ...
- sphinx cmd command
D:\iso\gaoqiao\app\sphinx\bin\indexer.exe -c D:\iso\gaoqiao\app\sphinx\bin\sphinx.conf --all --rotat ...
- CSS继承性+层叠性+盒子+浮动
CSS继承性+层叠性+盒子+浮动 CSS继承性 <style> div{ color: pink; font-siz ...
- GraphLab介绍[转]
GraphLab介绍 原文链接:http://blog.jasonding.top/2015/06/08/Machine%20Learning/%E5%BC%80%E6%BA%90%E5%9B%BE% ...
- MAC OS 快捷键一览
OS X 键盘快捷键 键盘快捷键是通过按下键盘上的组合键来调用 OS X 功能的一种方式.了解有关常见 OS X 键盘快捷键的信息. 若要使用键盘快捷键,您可以同时按修饰键和字符键.例如,按下 Com ...
- checkbox批量操作
hang=data.split("\1");//获取 查询返回的数据 处理数据 var str=""; for(var i =0;i<hang.lengt ...
- ios 显示其他app的购买页面
using UnityEngine; using System.Collections; using System.Runtime.InteropServices ; public class IOS ...