直达–>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. javascript 心得

    1.&&和||等逻辑判断运算标记可以当成条件运算来使用例如: var a =  b = c = "12"; (a=="13"&& ...

  2. grub2添加win引导(未试用)

    http://www.ruesin.com/system/centos/centos7-grub2-193.html

  3. html5 兼容火狐 ev的事件

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. appium 九宫格解锁招商银行手机客户端app

    之前研究了一段时间的appium for native app 相应的总结如下:                                            appium测试环境搭建 :ht ...

  5. ajax 设置同步

    这个问题总是碰见,但是又总是记不住怎么拼写,这次直接写出来,长期保存. Ajax请求默认的都是异步的 如果想同步 async设置为false就可以(默认是true) 例如: $.ajax({      ...

  6. js学习进阶中-bind()方法

    有次面试遇到的,也是没说清楚具体的作用,感觉自己现在还是没有深刻的理解! bind():绑定事件类型和处理函数到DOM element(父元素上) live():绑定事件到根节点上,(document ...

  7. ios 获取文件扩展名备忘

    NSString *lastComponent = [cachePath lastPathComponent];              NSString *pathLessFilename = [ ...

  8. Java笔记:文件夹操作

    创建目录: File类中有两个方法可以用来创建文件夹: mkdir( )方法创建一个文件夹,成功则返回true,失败则返回false.失败表明File对象指定的路径已经存在,或者由于整个路径还不存在, ...

  9. unity的固定管线shader

    最近shader学习中,看的视频. 练习的固定管线的shader如下: ps.在unity5中半透明不好用,其他的还好 //不区分大小写 //这是固定管线的Shader Shader "Sh ...

  10. EditView 输入限制(软键盘限制)

    众所周知EditView有个inputType 属性可以设置输入的类型. 如下设置,则只能输入数字: android:inputType="number" 但是有时候需要自定义输入 ...