ZOJ 2850和ZOJ 1414
下午上数据结构,结果竟然没有新题。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的更多相关文章
- zoj 2850 Beautiful Meadow
Beautiful Meadow Time Limit: 2 Seconds Memory Limit: 65536 KB Tom's Meadow Tom has a meadow in ...
- ZOJ 2723 Semi-Prime ||ZOJ 2060 Fibonacci Again 水水水!
两题水题: 1.如果一个数能被分解为两个素数的乘积,则称为Semi-Prime,给你一个数,让你判断是不是Semi-Prime数. 2.定义F(0) = 7, F(1) = 11, F(n) = F( ...
- 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 ...
- 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 ...
- 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 ...
- Zoj 3781(构造)
Zoj 3781(构造) Zoj 3781 As we all know, Coach Gao is a talented chef, because he is able to cook M dis ...
- Google, FaceBook, Amazon 加州求职记 (转)
http://blog.csdn.net/ithomer/article/details/8774006 http://www.myvisajobs.com 一年多前,出于显而易见的原因,下定决心肉身 ...
- 各大oj题目分类(转)
POJ题目分类 | POJ题目分类 | HDU题目分类 | ZOJ题目分类 | SOJ题目分类 | HOJ题目分类 | FOJ题目分类 | 模拟题: POJ1006POJ1008POJ1013POJ1 ...
- ZOJ 1414:Number Steps
Number Steps Time Limit: 2 Seconds Memory Limit: 65536 KB Starting from point (0,0) on a plane, ...
随机推荐
- 在jsp页面中导入BootStrap中的文件
BootStrap应该放在项目的根目录下面 然后因为我的jsp页面跟html页面是写在HTML文件夹中,所以我路径的导入应该像下面的图一样,退回到上级目录再写路径.
- Vue v-if v-for v-bind v-on
v-if <div v-if="type === 'A'"> A </div> <div v-else-if="type === 'B'&q ...
- POJ 2394 Dijkstra
题意: 思路: 裸的Dijkstra 爆敲一发模板 //By SiriusRen #include <queue> #include <cstdio> #include < ...
- OpenCV —— 轮廓
把检测出的边缘像素组装成轮廓 —— cvFindContours OpenCV 使用内存存储器来统一管理各种动态对象的内存.内存存储器在底层被实现为一个有许多相同大小的内存块组成的双向链表 内存储 ...
- JS面向对象:
面向对象:--JS系统对象也是基于原型的程序--不要修改或者添加系统对象下面的方法和属性eg: var arr = [1,2,3]; Array.prototype.push = function() ...
- wget---从指定的URL下载文件
wget命令用来从指定的URL下载文件.wget非常稳定,它在带宽很窄的情况下和不稳定网络中有很强的适应性,如果是由于网络的原因下载失败,wget会不断的尝试,直到整个文件下载完毕.如果是服务器打断下 ...
- 洛谷——P1314 聪明的质监员
https://www.luogu.org/problem/show?pid=1314 题目描述 小T 是一名质量监督员,最近负责检验一批矿产的质量.这批矿产共有 n 个矿石,从 1到n 逐一编号,每 ...
- Python和C|C++的混编(二):利用Cython进行混编
还能够使用Cython来实现混编 1 下载Cython.用python setup.py install进行安装 2 一个实例 ① 创建helloworld文件夹 创建helloworld.pyx,内 ...
- android 弹幕评论效果
纯粹依照自己的想法仿照b站的弹幕写的一个demo,不知道正确的姿势怎么样的. demo下载地址 首先.一条弹幕就是一个textview public abstract class Danmu exte ...
- js09--函数 call apply
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...