直达–>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)的更多相关文章

  1. Codeforces Round #368 (Div. 2) C. Pythagorean Triples(数学)

    Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a ...

  2. Codeforces Round #368 (Div. 2) B. Bakery (模拟)

    Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bak ...

  3. Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)

    Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...

  4. Codeforces Round #368 (Div. 2) D. Persistent Bookcase

    Persistent Bookcase Problem Description: Recently in school Alina has learned what are the persisten ...

  5. Codeforces Round #368 (Div. 2)D. Persistent Bookcase DFS

    题目链接:http://codeforces.com/contest/707/my 看了这位大神的详细分析,一下子明白了.链接:http://blog.csdn.net/queuelovestack/ ...

  6. Codeforces Round #368 (Div. 2) E. Garlands 二维树状数组 暴力

    E. Garlands 题目连接: http://www.codeforces.com/contest/707/problem/E Description Like all children, Ale ...

  7. Codeforces Round #368 (Div. 2) D. Persistent Bookcase 离线 暴力

    D. Persistent Bookcase 题目连接: http://www.codeforces.com/contest/707/problem/D Description Recently in ...

  8. Codeforces Round #368 (Div. 2) C. Pythagorean Triples 数学

    C. Pythagorean Triples 题目连接: http://www.codeforces.com/contest/707/problem/C Description Katya studi ...

  9. Codeforces Round #368 (Div. 2) B. Bakery 水题

    B. Bakery 题目连接: http://www.codeforces.com/contest/707/problem/B Description Masha wants to open her ...

随机推荐

  1. intellij idea Maven 创建项目时出现的一些问题

    1.关于maven仓库的问题 在下载资源的时候特别慢,原因是因为天朝的网络你们都懂的.解决方式使用国内镜像,原本可以用的OSChina的镜像,由于其服务器关闭,现在无法使用. 解决方案是使用阿里云的m ...

  2. using 声明与编译指令

    using std::cout; // using 声明 using namespace std; // using 编译指令,导入std里面的所有名称 一般使用using 声明,它只会导入指定的名称 ...

  3. C# 验证类(使用正则表达式 验证文本框)

    using System; using System.Text.RegularExpressions; namespace SG_VQCDataCollection { /// <summary ...

  4. PHP获取某月天数

    方式一: <?php function days($year,$month){ if($month<10){ $month = '0'.$month; } if($month == 12) ...

  5. string类型转换int类型

    C++转换形式(C++11): int main(int argc, char* argv[]) { std::"; std::string str2 = "3.14159&quo ...

  6. Mongo基础使用,以及在Express项目中使用Mongoose

    MongoDB的基本使用 MongoDB特点: 使用BSON存储数据 支持相对丰富的查询操作(相对其他nosql数据库) 支持索引 副本集(支持多个实例/多个服务器运行同个数据库) 分片(数据库水平扩 ...

  7. Firefox Portable Developer 52.0.0.6176-6178

    FirefoxPortableDeveloper-52.0.0.6176.7z 47.9 MB FirefoxPortableDeveloper-52.0.0.6178.7z 55.8 MB

  8. Cnblogs自定义皮肤css样式-星空观测者

    不知不觉来Cnblogs也这么久了,然而Blogs提供的主题还是依旧那么复古,总觉得阅读起来难免枯燥,虽然我认为做技术不可以太过浮躁,但是一个美观的主题终究是吸引人眼的第一要素. 毕竟这么久了,在博客 ...

  9. day6

    开发一个简单的python计算器 实现加减乘除及拓号优先级解析 用户输入 1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568 ...

  10. main 返回值

    int main() 在c中表示返回值时int:也可以不明确给出返回值,默认为int:()表示接受任何参数,main(void)表示不接受任何参数.main(),int main(),main(voi ...