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 ...
随机推荐
- The Safe Navigation Operator (&.) in Ruby
The most interesting addition to Ruby 2.3.0 is the Safe Navigation Operator(&.). A similar opera ...
- PYTHON 随机验证码生成
# 生成一个六位随机验证码 import random # random 生成随机数 temp = '' for i in range(6): num = random.randrange(0,6) ...
- Centos7下面配置静态IP
修改网卡配置文件(操作前先备份一下该文件),/etc/sysconfig/network-scripts/ifcfg-enp0s3 ,如下: TYPE=Ethernet BOOTPROTO=stati ...
- PhotoSwipe插件的使用
1.首先引入插件 <link rel="stylesheet" href="css/photoswipe.css"> <link rel=&q ...
- 【JSTREE】 复选框默认选中【总结】
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...
- EndNote(一)之基本介绍
作为一个经常看文献的人,发现看了很多文献,但是之后需要再找某一篇文献的时候,却无法找到文献在哪里了.混乱的文献管理方式,浪费了很多时间在翻阅自己已经看过的文献之中.这是一件很头痛的事情,才想起借助软件 ...
- Reverse Core 第三部分 - 21章 - Windows消息钩取
@author: dlive @date: 2016/12/19 0x01 SetWindowsHookEx() HHOOK SetWindowsHookEx( int idHook, //hook ...
- Ansible 模块命令介绍
copy模块: 目的:把主控端/root目录下的a.sh文件拷贝到到指定节点上 命令:ansible 10.1.1.113 -m copy -a 'src=/root/a.sh dest=/tmp/' ...
- Ruby混合类型
当一个类拥有可以从多个父类继承的特点,类应该显示多重继承. Ruby没有直接支持多继承,但Ruby模块有另一个精彩使用.他们几乎消除多重继承的需要,提供了一个工厂,称为混入. 混合类型给一个精彩的控制 ...
- javase-->基础知识(一)
1.JDK安装和和配置 1)安装jdk1.8版本(不同的平台安装不同的jdk). 2)配置:将.../jdk1.x/bin放到path环境变量的最前面(避免之前配的环境变量干扰). ****** ja ...