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, ...
随机推荐
- jquery13 attr() prop() val() addClass()等 : 对元素属性的操作
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...
- RTSP传输协议之Methods总结
RTSP/1.0 200 OK Server: DSS/5.5.5 (Build/489.16; Platform/Linux; Release/Darwin; state/beta; ) Cseq: ...
- DOM节点的创建、插入、删除、查找、替换
在前端开发中,js与html联系最紧密的莫过于对DOM的操作了,本文为大家分享一些DOM节点的基本操作. 一.创建DOM节点 使用的命令是 var oDiv = document.createElem ...
- Linux LiveCD 诞生记
Linux LiveCD 诞生记 650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic ...
- MATLAB —— 编程基础
字符串 abs —— 输出字符串ascii码 strvcat —— 把多个字符串横向连接成长字符串 fprintf —— 把格式化的文本写到文件中或显示屏上 int2str —— 整数转换成字符串 n ...
- call(),apply()和bind()的详解使用:
obj.call(thisObj, arg1, arg2, ...); obj.apply(thisObj, [arg1, arg2, ...]); 两者作用一致,都是把obj(即this)绑定到th ...
- python 数字计算模块 decimal(小数计算)
from decimal import * a = Decimal('0.1')+Decimal('0.1')+Decimal('0.1')+Decimal('0.3') float(a) >& ...
- [ReasonML] Workshops code
/* list of strings */ let _ = ["example-1", "example-2", "example-3"]; ...
- 44.delete用法
声明+delete:函数禁止使用.可以使一个类禁止释放
- TrueSec引导的Linux系统和安全检测工具预览
650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=&qu ...