找到规律,各一个种一棵树。或者施肥。先施肥,先种树一样。

Apple Tree

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)

Total Submission(s): 197    Accepted Submission(s): 135

Problem Description
I’ve bought an orchard and decide to plant some apple 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?
 
Input
The input contains multiple test cases. The number of 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.
 
Output
For each test case, you should output the maximum number of apples I can obtain.
 
Sample Input
2
2 2
3 3
 
Sample Output
8
32
 

#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#define eps 1e-12
///#define M 1000100
#define LL __int64
///#define LL long long
///#define INF 0x7ffffff
#define INF 0x3f3f3f3f
#define PI 3.1415926535898
#define zero(x) ((fabs(x)<eps)?0:x) using namespace std; const int maxn = 110; int mp[maxn][maxn]; int main()
{
int n, m;
int T;
cin >>T;
while(T--)
{
scanf("%d %d",&n, &m);
memset(mp, 0, sizeof(mp));
for(int i = 1; i <= n; i++)
{
if(i%2)
{
for(int j = 1; j <= m; j += 2)
mp[i][j] = 1;
}
else
{
for(int j = 2; j <= m; j+= 2)
mp[i][j] = 1;
}
}
LL sum = 0;
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m; j++)
{
if(mp[i][j]) continue;
int cnt = 0;
if(i-1 >= 1) if(mp[i-1][j]) cnt ++;
if(i+1 <= n) if(mp[i+1][j]) cnt ++;
if(j-1 >= 1) if(mp[i][j-1]) cnt++;
if(j+1 <= m) if(mp[i][j+1]) cnt++;
sum += (1LL<<cnt);
}
}
if(sum == 0)
sum++;
cout<<sum<<endl;
}
}

HDU 4925 Apple Tree (瞎搞)的更多相关文章

  1. HDU 4925 Apple Tree(推理)

    HDU 4925 Apple Tree 题目链接 题意:给一个m*n矩阵种树,每一个位置能够选择种树或者施肥,假设种上去的位置就不能施肥,假设施肥则能让周围果树产量乘2.问最大收益 思路:推理得到肯定 ...

  2. HDU 4925 Apple Tree(模拟题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4925 解题报告:给你n*m的土地,现在对每一块土地有两种操作,最多只能在每块土地上进行两种操作,第一种 ...

  3. 2014多校第六场 1005 || HDU 4925 Apple Tree

    题目链接 题意 : 给你一块n×m的矩阵,每一个格子可以施肥或者是种苹果,种一颗苹果可以得到一个苹果,但是如果你在一个格子上施了肥,那么所有与该格子相邻(指上下左右)的有苹果树的地方最后得到的苹果是两 ...

  4. 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 ...

  5. hdoj 4925 Apple tree 【最小割】

    题目:pid=4925">hdoj 4925 Apple tree 来源:2014 Multi-University Training Contest 6 题意:给出一个矩阵,然后每一 ...

  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 ...

  7. HDU 2222 Keywords Search(瞎搞)

    Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others ...

  8. hdu 4786 Fibonacci Tree 乱搞 智商题目 最小生成树

    首先计算图的联通情况,如果图本身不联通一定不会出现生成树,输出"NO",之后清空,加白边,看最多能加多少条,清空,加黑边,看能加多少条,即可得白边的最大值与最小值,之后判断Fibo ...

  9. HDU-4925 Apple Tree

    http://acm.hdu.edu.cn/showproblem.php?pid=4925 Apple Tree Time Limit: 2000/1000 MS (Java/Others)     ...

随机推荐

  1. POJ 2082 Terrible Sets(单调栈)

    [题目链接] http://poj.org/problem?id=2082 [题目大意] 给出一些长方形下段对其后横向排列得到的图形,现在给你他们的高度, 求里面包含的最大长方形的面积 [题解] 我们 ...

  2. [CodeChef-LVGFT]Lovers Gift

    题目大意: 给定一个$n(n\le10^5)$个结点的树,初始全为白点.$m(m\le10^5)$次操作,每次将点$x$染成黑色或询问从$x$出发至少经过一个黑点能到达的点中,编号次大的点. 思路: ...

  3. Problem H: 计算数列和2/1,3/2,5/3,8/5......

    #include<stdio.h> int main(){ int i,n; scanf("%d",&n); float sum=0.0; ; ; ;i< ...

  4. Why DNS Based Global Server Load Balancing (GSLB) Doesn’t Work

    Why DNS Based Global Server Load Balancing (GSLB) Doesn't Work    

  5. JAVA call graphs JAVA调用图

    https://github.com/gousiosg/java-callgraph Programs for producing static and dynamic (runtime) call ...

  6. Delphi 获取sqlite中所有的表名

    取得sqlite数据库里所有的表名 查询table,type 段是'table',name段是table的名字, so: select name from sqlite_master where ty ...

  7. 解决小米手机Android Studio安装app 报错的问题It is possible that this issue is resolved by uninstalling an existi

    问题描述 Android Studio升级到2.3版本之后,小米手机MIUI8不能运行Android Studio程序,报如下错误: Installation failed with message  ...

  8. jquery如何判断元素是否被点击、属性操作、class操作

    1.通过点击事件发生后,改变标志位的值,记录点击状态 function(){ var isClick = false; $('#test').click(function(){isClick = tr ...

  9. asp.net权限控制的方式

    我们在使用asp.net开发Web程序的时候经常需要进行一些权限控制,如: 限制用户没有登陆就无法查看一些页面,又或者是说登陆之后如果不是管理员,或是没有响应的权限就无法进行相关的操作. 实现的方法有 ...

  10. Kafka查看偏移量报错:WARN WARNING: ConsumerOffsetChecker is deprecated and will be dropped in releases following 0.9.0. Use ConsumerGroupCommand instead.

    Kafka0.9版本后,命令ConsumerOffsetChecker已弃用,用新的命令来查. // 列表 bin/kafka-consumer-groups.sh --zookeeper local ...