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

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. [姿势]cpp - memset

    头文件:memory.h 可以刷的有: memset(array,,sizeof(array)); //全部赋0 memset(array,-,sizeof(array)); //全部赋-1 用法和用 ...

  2. [Atcoder SHPC2018] Tutorial

    Link: SHPC2018 传送门 C: 一道看上去有些吓人的题目,不过$1e9$规模下的$n^m$代表肯定是可以约分的 可以发现能提供贡献的数对只有$2*(n-d)$种,那么总贡献为$2*(n-d ...

  3. 【数论】【欧拉函数】【筛法求素数】【乘法逆元】【快速幂取模】bzoj2186 [Sdoi2008]沙拉公主的困惑

    http://www.cnblogs.com/BLADEVIL/p/3490321.html http://www.cnblogs.com/zyfzyf/p/3997986.html 翻了翻题解,这两 ...

  4. 【二分答案】【最短路】bzoj1614 [Usaco2007 Jan]Telephone Lines架设电话线

    对于二分出的答案x而言,验证答案等价于将所有边权>x的边赋成1,否则赋成0,然后判断从1到n的最短路是否<=K. #include<cstdio> #include<cs ...

  5. cocos2d 文件系统使用文件内存映射性能对比

    //cocos 修改代码 ..... //性能测试代码 extern "C" { #include <time.h> #include <stdlib.h> ...

  6. oracle表空间操作语句

    1.查看所有表空间及表空间大小: select tablespace_name ,sum(bytes) / 1024 / 1024 as MB from dba_data_files group by ...

  7. solr 统计频率(term frequency)

    1.统计单词在某个字段出现的频率次数 term frequency实现使用了function query. 例如统计‘公司’这个关键字在text这个字段中出现的次数 在返回的时候进行计算统计,即在返回 ...

  8. Windows命令行报错:'findstr' 不是内部或外部命令,也不是可运行的程序或批处理文件

    环境变量Path中追加:%SystemRoot%/system32;%SystemRoot%;

  9. 伟大的UHD编解码器的辩论:谷歌VP9与HEVC / H.265

    伟大的UHD编解码器的辩论:谷歌VP9与HEVC / H.265 截至今天,伟大的UHD编解码器的争论涉及两个主要参与者:谷歌VP9和HEVC / H.265. 哪一个获得成功并where-invol ...

  10. 对AOP切面的一些整理与理解

      首先上一张AOP的图示 一:几个重要的概念   1> 切面:横切关注点(跨越应用程序多个模块的功能)被模块化的特殊对象[验证切面.日志切面]   2> 通知:切面中的每个方法   3& ...