下午上数据结构,结果竟然没有新题。T T果断上OJ来水一发

ZOJ 2850   Beautiful Meadow

传送门http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2850

题目判断yes的条件为

不是所有的格子都是草地,并且相邻不能没有草地。

#include<cstdio>
#include<iostream>
using namespace std;
const int MAXN=12;
int area[MAXN][MAXN];
int N,M; bool ok()
{
for(int i=0;i<N;i++)
{
for(int j=0;j<M;j++)
{ // cout<<area[i][j]<<" "<<area[i+1][j]<<endl; if(i>0 && area[i-1][j]==0 && area[i][j]==0)
return 0;
if(j>0 && area[i][j-1]==0 && area[i][j]==0)
return 0;
if(i<N-1 && area[i+1][j]==0 && area[i][j]==0)
return 0;
if(j<M-1 && area[i][j+1]==0 && area[i][j]==0)
return 0; } }
return true;
} int main()
{ while(scanf("%d%d",&N,&M),N||M)
{
bool allone=true; for(int i=0;i<N;i++)
{
for(int j=0;j<M;j++)
{
scanf("%d",&area[i][j]);
if(area[i][j]==0)
allone=false;
}
} if( !allone && ok())
printf("Yes\n");
else
printf("No\n");
}
}

ZOJ 1414 Number Steps

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1414

找x和y的关系就好

#include<cstdio>
int main()
{
int N;
scanf("%d",&N);
while(N--)
{
int x,y;
scanf("%d%d",&x,&y);
if(x-y==2 || x==y)
{
if(x%2==0)
printf("%d\n",x+y);
else
printf("%d\n",x+y-1); }
else
printf("No Number\n");
}
}

ZOJ 2850和ZOJ 1414的更多相关文章

  1. zoj 2850 Beautiful Meadow

    Beautiful Meadow Time Limit: 2 Seconds      Memory Limit: 65536 KB Tom's Meadow Tom has a meadow in ...

  2. ZOJ 2723 Semi-Prime ||ZOJ 2060 Fibonacci Again 水水水!

    两题水题: 1.如果一个数能被分解为两个素数的乘积,则称为Semi-Prime,给你一个数,让你判断是不是Semi-Prime数. 2.定义F(0) = 7, F(1) = 11, F(n) = F( ...

  3. ZOJ 3910 Market ZOJ Monthly, October 2015 - H

    Market Time Limit: 2 Seconds      Memory Limit: 65536 KB There's a fruit market in Byteland. The sal ...

  4. ZOJ 3905 Cake ZOJ Monthly, October 2015 - C

    Cake Time Limit: 4 Seconds      Memory Limit: 65536 KB Alice and Bob like eating cake very much. One ...

  5. ZOJ 3903 Ant ZOJ Monthly, October 2015 - A

    Ant Time Limit: 1 Second      Memory Limit: 32768 KB There is an ant named Alice. Alice likes going ...

  6. Zoj 3781(构造)

    Zoj 3781(构造) Zoj 3781 As we all know, Coach Gao is a talented chef, because he is able to cook M dis ...

  7. Google, FaceBook, Amazon 加州求职记 (转)

    http://blog.csdn.net/ithomer/article/details/8774006 http://www.myvisajobs.com 一年多前,出于显而易见的原因,下定决心肉身 ...

  8. 各大oj题目分类(转)

    POJ题目分类 | POJ题目分类 | HDU题目分类 | ZOJ题目分类 | SOJ题目分类 | HOJ题目分类 | FOJ题目分类 | 模拟题: POJ1006POJ1008POJ1013POJ1 ...

  9. ZOJ 1414:Number Steps

    Number Steps Time Limit: 2 Seconds      Memory Limit: 65536 KB Starting from point (0,0) on a plane, ...

随机推荐

  1. 3.索引与string进行映射实现高效查找

    #include <iostream> #include <typeindex>//类型索引 #include <unordered_map>//红黑树 #incl ...

  2. 认知 Git 和 GitHub

    今天被一个大牛的大哥问了个问题,问住了.原问题是“你是到github吗?git呢?” 我堂而皇之的说,“他们不是同一个吗?” 结果大牛大哥狠狠地回了我一句“百度去”..好吧我乖乖去百度了. 这是我百度 ...

  3. javaweb三、JDBC访问数据库

    JDBC是J2SE的内容,是由java提供的访问数据库的接口,但没有提供具体的实现方法,需要数据库厂商提供,就是对应的数据库驱动. 这样的好处是可以方便的更换数据库,提高了扩展性.这也是面向接口编程的 ...

  4. Self-Taught Learning

    the promise of self-taught learning and unsupervised feature learning is that if we can get our algo ...

  5. postgresql 不同数据库不同模式下的数据迁移

    编写不容易,转载请注明出处谢谢, 数据迁移 因为之前爬虫的时候,一部分数据并没有上传到服务器,在本地.本来用的就是postgresql,也没用多久,数据迁移的时候,也遇到了很多问题,第一次使pg_du ...

  6. hdu 6170

    dp: http://blog.csdn.net/qq_28954601/article/details/77484676 #include <bits/stdc++.h> #define ...

  7. linux 配置IP地址

    linux 配置IP网址能够使用neat,netconfig,ifconfig等进行配置,当中前两个实用户界面,第三个命令仅仅是暂时设置IP,机器重新启动后配置将丢失. 有时候图形用户界面的程序难以获 ...

  8. js40---享元模式

    /** * 享元模式是一个为了提高性能(空间复杂度)的设计模式 * 他使用与程序会生产大量的相类似的对象是耗用大量的内存的问题 */ (function(){ /** * 制造商 * 型号 * 拥有者 ...

  9. 19,tuple多元数组

    #include <iostream> #include <tuple> using namespace std; void main() { char ch = 'a'; ; ...

  10. Elasticsearch之插件扩展

    Elasticsearch之插件介绍及安装 Elasticsearch之head插件安装之后的浏览详解 Elasticsearch之kopf插件安装之后的浏览详解 Elasticsearch-2.4. ...