下午上数据结构,结果竟然没有新题。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. Get Started with Git and Team Services

    https://www.visualstudio.com/en-us/docs/git/gitquickstart Visual Studio查看日志 LocalHistory和Incoming是拆开 ...

  2. AC自动机 hdu2222

    #include <iostream> using namespace std; struct Node{ Node *next[]; Node* fail; int count; Nod ...

  3. Qwt库的一个使用注意事项

    作者:朱金灿 来源:http://blog.csdn.net/clever101 一般debug版本的程序链接release版本的库是没有问题的.今天使用debug版本程序链接release版本的qw ...

  4. [ Java ] [ Eclipse ] 加速 Eclipse 載入速度-轉載

    加速 Eclipse 載入速度-轉載 https://read01.com/NJjNOB.html

  5. 【2017 Multi-University Training Contest - Team 5】Rikka with Subset

    [Link]: [Description] 给你a数组的n个数的所有2^n个子集的2^n个子集元素的和; 子集元素的和最大为m; 告诉你各个子集元素的和出现的次数; 如 1 2 则0出现1次,1出现1 ...

  6. [Python] List & Object spread in Python

    def myfunc(x, y, z): print(x, y, z) tuple_vec = (, , ) dict_vec = {, , } >>> myfunc(*tuple_ ...

  7. Java开发者最经常使用19个Linux命令

    1.查找文件 find / -name filename.txt 依据名称查找/文件夹下的filename.txt文件. 2.查看一个程序是否执行 ps –ef|grep tomcat 查看全部有关t ...

  8. 码农的救赎:使用Github Pages搭建博客

    人生若仅仅如初见,都恨太晚 据说有博客的人比没博客人的薪水要高非常多,相传写博客也是一个高手的标配,尽管之前一直有在写(在这里).可是孤既不是高手.薪水还比别人少.之前一直在CSDN上面写博客,那是一 ...

  9. screen-调节屏幕亮度

    今天做项目的时候,需要实现一个功能,就是进入一个应用,在这个应用中,屏幕的亮度变为最亮.关键代码如下 bt1.setOnClickListener(new OnClickListener() { @O ...

  10. Android 通过局域网udp广播自动建立socket连接

    Android开发中经常会用到socket通讯.由于项目需要,最近研究了一下这方面的知识. 需求是想通过wifi实现android移动设备和android平台的电视之间的文件传输与控制. 毫无疑问这中 ...