Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2)
A Brain’s Photos
给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输出”#Color”,如果只有”G”,”B”,”W”就输出”#Black&White”。
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 200;
const int INF = 0x3f3f3f;
char P[maxn][maxn];
int m,n;
int flag;
int main()
{
scanf("%d%d",&n,&m);
flag = 0;
getchar();
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
scanf("%c",&P[i][j]);
getchar(); //注意字符串的输入
if(P[i][j]=='C'||P[i][j]=='M'||P[i][j]=='Y')//莫名其妙忽略了灰色。醉醉哒
flag = 1;
}
}
if(flag) printf("#Color\n");
else printf("#Black&White\n");
return 0;
}
B Bakery
我以为是固定起点最短路,终点是仓库任意一个求最短,题目英文长的可怕,结果才发现弄错了,是求任意一个城市仓库到普通城市的最短路径。用vis数组存仓库的标号,判定是否有城市仓库和普通城市连通选最短。
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn = 100000+5;
const int INF = 0x3f3f3f3f;
int s[maxn];
int n,m,k;
int nn[maxn],mm[maxn];
int kk[maxn];
int main()
{
int ans = INF;
scanf("%d%d%d",&n,&m,&k);
int a,b,c;
for(int i=0;i<m;i++){
scanf("%d%d%d",&a,&b,&c);
nn[i] = a;
mm[i] = b;
s[i] = c;
}
if(k==0||k==n){
printf("-1\n");
return 0;
}
for(int i=0;i<k;i++){
scanf("%d",&a);
kk[a] = 1;
}
for(int i=0;i<m;i++){
if((!kk[nn[i]]&&kk[mm[i]])||(!kk[mm[i]]&&kk[nn[i]])){
//printf("%d %d %d\n",i,nn[i],mm[i]);
ans = min(ans,s[i]);
}
}
if(ans==INF) printf("-1\n");
else printf("%d\n",ans);
return 0;
}
C Pythagorean Triples
给你一个直角三角形的某一个边长,求出直角三角形其他两个边的边长。这题网上找的规律:(然后注意下数据大小就OK了)
当a为大于1的奇数2n+1时,b=2n2+2n,c=2n2+2n+1
当a为大于4的偶数2n时,b=n2−1,c=n2+1
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
long long n,m,k;
int main()
{
scanf("%I64d",&n);
if(n<=2) printf("-1\n");
else{
if(n&1){
n = (n-1)/2;
printf("%I64d %I64d\n",2*n*n+2*n,2*n*n+2*n+1);
}
else{
n = n/2;
printf("%I64d %I64d\n",n*n-1,n*n+1);
}
}
return 0;
}
Codeforces Round #368 (Div. 2)的更多相关文章
- 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) D. Persistent Bookcase
Persistent Bookcase Problem Description: Recently in school Alina has learned what are the persisten ...
- Codeforces Round #368 (Div. 2)D. Persistent Bookcase DFS
题目链接:http://codeforces.com/contest/707/my 看了这位大神的详细分析,一下子明白了.链接:http://blog.csdn.net/queuelovestack/ ...
- Codeforces Round #368 (Div. 2) E. Garlands 二维树状数组 暴力
E. Garlands 题目连接: http://www.codeforces.com/contest/707/problem/E Description Like all children, Ale ...
- Codeforces Round #368 (Div. 2) D. Persistent Bookcase 离线 暴力
D. Persistent Bookcase 题目连接: http://www.codeforces.com/contest/707/problem/D Description Recently in ...
- Codeforces Round #368 (Div. 2) C. Pythagorean Triples 数学
C. Pythagorean Triples 题目连接: http://www.codeforces.com/contest/707/problem/C Description Katya studi ...
- Codeforces Round #368 (Div. 2) B. Bakery 水题
B. Bakery 题目连接: http://www.codeforces.com/contest/707/problem/B Description Masha wants to open her ...
随机推荐
- word20161220
S/MIME, Secure Multipurpose Internet Mail Extensions / 安全多用途网际邮件扩展协议 SACL, system access control lis ...
- 微信的audio无法自动播放的问题
一.问题 最近做了一个html5的项目,里面涉及到音乐播放,项目要求音乐进入页面就自动播放,于是我就想到了html5的audio标签,将mp3引入进去. 1.在audio标签里引入了autoplay属 ...
- ms08-067漏洞--初识渗透测试--想必很多初学者都会遇到我文中提及的各种问题
最近读了一本书--<<渗透测试实践指南>>,测试了书中的一些例子后,开始拿ms08-067这个经典的严重漏洞练手,实践当中遇到诸多问题,好在一一解决了,获益匪浅. 在谷歌搜索的 ...
- html5 拖拽函数1--不兼容火狐
拖拽元素事件<br/>ondragstart拖拽前触发<br/>ondrag拖拽结束之前连续触发<br/>ondragend 拖拽结束前触发<br/>目 ...
- tengine/nginx-tomcat动静分离遇到的问题
小站安装好tengine后,接下来的工作就是要配置好tengine让其和后端的tomcat正常的连接工作起来,tengine的配置文件本身比较简单,网上有大量的相关介绍说明文档,我这里只是摘出我配置过 ...
- highcharts使用笔记
1.legend取消点击事件: 饼图:plotOptions.pie.point.events.legendItemClick = function() {return false;} 其他,如:pl ...
- 关于datepicker只显示年、月、日的设置
关键时侯,还得看官方文档.花了半个多小时,找了网上一大堆答复,然后一一验证,90%没有能解决问题. 先给出官方文档的URL: http://bootstrap-datepicker.readthedo ...
- Python: Windows 7 64位 安装、使用 pymongo 3.2
官网tutorial: http://api.mongodb.com/python/current/tutorial.html 本教程将要告诉你如何使用pymongo模块来操作MongoDB数据库. ...
- cookie的存储和获取
在做用户登录时经常会用到cookie,如何将用户名和密码保存至cookie中呢?如何获取cookie中的数据呢? 一.用jquery.cookie.js保存数据 在页面内引入jQuery.cookie ...
- Spring + Jedis集成Redis(集群redis数据库)
前段时间说过单例redis数据库的方法,但是生成环境一般不会使用,基本上都是集群redis数据库,所以这里说说集群redis的代码. 1.pom.xml引入jar <!--Redis--> ...