HDU-4925 Apple Tree
http://acm.hdu.edu.cn/showproblem.php?pid=4925
Apple Tree
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 120 Accepted Submission(s):
82
trees on it. The orchard seems like an N * M two-dimensional map. In each grid,
I can either plant an apple tree to get one apple or fertilize the soil to speed
up its neighbors’ production. When a grid is fertilized, the grid itself doesn’t
produce apples but the number of apples of its four neighbor trees will double
(if it exists). For example, an apple tree locates on (x, y), and (x - 1, y),
(x, y - 1) are fertilized while (x + 1, y), (x, y + 1) are not, then I can get
four apples from (x, y). Now, I am wondering how many apples I can get at most
in the whole orchard?
test cases T (T<=100) occurs in the first line of input.
For each test
case, two integers N, M (1<=N, M<=100) are given in a line, which denote
the size of the map.
number of apples I can obtain.
- #include<iostream>
- #include<cstring>
- #include<cstdio>
- using namespace std;
- int n;
- int main()
- {
- int n,m,map[][],i,j,t;
- scanf("%d",&t);
- while(t--)
- {
- scanf("%d%d",&n,&m);
- memset(map,,sizeof(map));
- for(i=;i<=n;i++)
- {
- for(j=;j<=m;j++)
- {
- map[i][j]=-;
- if((i%==)&&(j%==))
- map[i][j]=;
- if((i%==)&&(j%==))
- map[i][j]=;
- }
- }
- int a,b;
- for(i=;i<=n;i++)
- for(j=;j<=m;j++)
- {
- if(map[i][j]==)
- {
- if(map[i-][j]==-&&i->=)
- {
- map[i][j]*=;
- }
- if(map[i][j-]==-&&j->=)
- {
- map[i][j]*=;
- }
- if(map[i+][j]==-&&i+<=n)
- {
- map[i][j]*=;
- }
- if(map[i][j+]==-&&j+<=m)
- {
- map[i][j]*=;
- }
- }
- }
- int ans=;
- for(i=;i<=n;i++)
- for(j=;j<=m;j++)
- {
- if(map[i][j]!=-)
- ans+=map[i][j];
- }
- printf("%d\n",ans);
- }
- return ;
- }
HDU-4925 Apple Tree的更多相关文章
- HDU 4925 Apple Tree(推理)
HDU 4925 Apple Tree 题目链接 题意:给一个m*n矩阵种树,每一个位置能够选择种树或者施肥,假设种上去的位置就不能施肥,假设施肥则能让周围果树产量乘2.问最大收益 思路:推理得到肯定 ...
- HDU 4925 Apple Tree (瞎搞)
找到规律,各一个种一棵树.或者施肥.先施肥,先种树一样. Apple Tree Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 2621 ...
- HDU 4925 Apple Tree(模拟题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4925 解题报告:给你n*m的土地,现在对每一块土地有两种操作,最多只能在每块土地上进行两种操作,第一种 ...
- 2014多校第六场 1005 || HDU 4925 Apple Tree
题目链接 题意 : 给你一块n×m的矩阵,每一个格子可以施肥或者是种苹果,种一颗苹果可以得到一个苹果,但是如果你在一个格子上施了肥,那么所有与该格子相邻(指上下左右)的有苹果树的地方最后得到的苹果是两 ...
- hdu 4925 Apple Tree--2014 Multi-University Training Contest 6
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4925 Apple Tree Time Limit: 2000/1000 MS (Java/Others ...
- hdoj 4925 Apple tree 【最小割】
题目:pid=4925">hdoj 4925 Apple tree 来源:2014 Multi-University Training Contest 6 题意:给出一个矩阵,然后每一 ...
- 【HDU 4925】BUPT 2015 newbie practice #2 div2-C-HDU 4925 Apple Tree
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102419#problem/C Description I’ve bought an or ...
- HDU 6206 Apple (高精确度+JAVA BigDecimal)
Problem Description Apple is Taotao's favourite fruit. In his backyard, there are three apple trees ...
- POJ 2486 Apple Tree
好抽象的树形DP......... Apple Tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6411 Accepte ...
随机推荐
- jq版本更新后无live函数的处理.
之前你的代码如果是$("#ele").live("click", function() { //...});现在要写成$("#ele" ...
- (转)C# NameValueCollection集合
1.NameValueCollection类集合是基于 NameObjectCollectionBase 类. 但与 NameObjectCollectionBase 不同,该类在一个键下存储多个字符 ...
- java的集合框架之一
java是一套很成熟的东西,很多商用的东西都喜欢用它,用的人多,稳定.不过一般也不怎么说起它,因为太常见了,私下里说,写java应用层得就像农民工,每一处都是搭积木,根据设计师的东西如何优雅地搭好积木 ...
- C#当中的多线程_线程基础
前言 最近工作不是很忙,想把买了很久了的<C#多线程编程实战>看完,所以索性把每一章的重点记录一下,方便以后回忆. 第1章 线程基础 1.创建一个线程 using System; usin ...
- C++Primer学习笔记(二、基础)
1.两种初始化方式,直接初始化语法更灵活,且效率更高. ); // 直接初始化 direct-initialization ; // 赋值初始化 copy-initialization 2.const ...
- framework 4.5.1安装时发生严重错误
http://jingyan.baidu.com/article/a501d80c0a74b4ec630f5ee5.html http://jingyan.baidu.com/article/d807 ...
- obj.onclick=fnClick与obj.onclick=fnClick()的区别
先说结论:这段代码浏览器会报错,提示 aDiv[this.index] is undefined 所以正确的写法应该是去掉(),直接写为function fnClick. 不加括号的话,相当于指定 ...
- WinFrom ProgressBar控件的使用
在WinForm程序中,大多数情况下我们是知道程序运行所需要的时间或步骤的,比如批量复制文件时文件的数量,数据导出或导入时数据的总行数等等.对于步骤比较确定的操作,如果程序执行过程时间较长,很容易使用 ...
- javascript闭包传参和事件的循环绑定
今天看到一个javascript的题目,按常理循环绑定事件,但是得到的结果却不是想要的. <a href="#">text</a><br>< ...
- 把AS代码链接到fla文件
在属性里找到类,输入AS脚本的文件名然后点击右边的编辑就可以打开编辑AS脚本的界面,下面为链接代码. package { import flash.display.MovieClip; public ...