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 ...
随机推荐
- react+redux官方实例TODO从最简单的入门(6)-- 完结
通过实现了增-->删-->改-->查,对react结合redux的机制差不多已经了解,那么把剩下的功能一起完成吧 全选 1.声明状态,这个是全选状态 2.action约定 3.red ...
- C# 验证类(使用正则表达式 验证文本框)
using System; using System.Text.RegularExpressions; namespace SG_VQCDataCollection { /// <summary ...
- zabbix触发器依赖
触发器依赖 Zabbix - Router1 - Router2 – Host 如果router1宕机了,那么router2和host都不能连上,这样的话就会发router1.router2和host ...
- airflow 部署
环境 : ubuntu 14.04 LTS python 2.7 script: 设置环境变量: export AIRFLOW_HOME=~/airflow 安装相关依赖包: sudo apt-get ...
- Node.js配合node-http-proxy解决本地开发ajax跨域问题
情景: 前后端分离,本地前端开发调用接口会有跨域问题,一般有以下3种解决方法: 1. 后端接口打包到本地运行(缺点:每次后端更新都要去测试服下一个更新包,还要在本地搭建java运行环境,麻烦) 2. ...
- RSA非对称性前端加密后端解密
前端加密代码 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ...
- DIV+CSS布局
宽度自适应两列布局 <!DOCTYPE html> <html> <head> <meta charset="gbk"> <t ...
- JqueryUI Dialog 加载动态页 部分页
问题:使用JqueryUIDialog 加载部分页,可以弹出对话框,但是在操作页面上的按钮是提示"dialog"找不到,思路是,先取到部分页加载到要dialog的Div上,在dia ...
- RBAC基于角色的访问控制
RBAC(Role-Based Access Control,基于角色的访问控制),就是用户通过角色与权限进行关联.简单地说,一个用户拥有若干角色,每一个角色拥有若干权限.这样,就构造成"用 ...
- jquery简单的轮播效果!
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...