HDU 4925 Apple Tree (瞎搞)


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 For each test case, two integers N, M (1 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 #include #include #include #include #include #include #include #include #include #include #include #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)>T; while(T--) { scanf("%d %d",&n, &m); memset(mp, 0, sizeof(mp)); for(int i = 1; i = 1) if(mp[i-1][j]) cnt ++; if(i+1 = 1) if(mp[i][j-1]) cnt++; if(j+1

点击复制链接 与好友分享!回本站首页
上一篇:POJ 3292 Semi-prime H-numbers(数)
下一篇:HDU 1540 &&POJ 2892 Tunnel Warfare (线段树,区间合并).

Max Sum &&http://acm.hdu.edu.cn/s

hdu 1003 Max Sum

HDU 4007



hdu 1089 Robotic Sort

hdu 1754

HDU 4028


HDU 4022

HDU 4925 Apple Tree (瞎搞)
ZOJ 3640 Help Me
HDU 4925 Apple Tree (瞎搞)
CF 518C(Anya and
HDU 4925 Apple Tree (瞎搞)
hdu 1016 Prime R
UVA - 11987 - A

分类:默认分类 时间:2012-04-01 人气:3


  • hdu 4925 Apple Tree 2014-02-04

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4925 思路:直接计算坐标和,如果为奇数就种树,但要注意行或列为1的情况。 写啦两种代码:一种直接判断计算的,另一种优化计算的 code1: #include #include #include #include using namespace std; int main() { int T; scanf("%d",&T); while(T--) { int n,m,i,j; while(sc

  • HDU 4925 Apple Tree 找呀找规律 2014-12-30

    间隔着取_(:з?∠)_ #include #include #include using namespace std; typedef long long ll; int n, m; int init(int i, int j) { int cnt = 1; if(i-1 >= 1) cnt *= 2; if(i+1 = 1) cnt *= 2; if(j+1 0) { scanf("%d%d", &n, &m); if(n == 1 && m == 1)

  • POJ 3321 Apple Tree DFS + 树状数组 2012-06-17

    题意:一棵树树上有N个分叉点,分个分叉点上有一个苹果或者没有苹果,现在想知道以某一个分叉点为根节点的子树有多少苹果。 从题目的叙述中可以知道给出的数据并不是一棵二叉树,所以一开始往并查集的方向做,每次更新都要从当前节点一直更新到根节点。 当这棵树是一条单链的时候,这种做法的耗时就显得有点丧心病狂了。。。。 下面说正解。 此题其实为区间查询题,可是问题在于线段书只能查询一段连续的区间内的值,对于离散的点线段树就丝毫无用武之地了。 下面DFS这个大杀器就要粉墨登场了。 若对点重新用DFS时被访问的先

  • HDU4925-Apple Tree 2013-08-11

    题意:n*m网格中种苹果,每个网格要么施肥,要么种一个苹果,每个种苹果的格子,如果它的上下左右有各自有施肥的话,每有一个,苹果数量*2,求怎么种使得苹果数量最多。 思路:交叉种植,即黑白染色法可得到最优解。注意特判当n=m=1时的情况。 #include #include #include #include using namespace std; const int MAXN = 105; int n, m; int g[MAXN][MAXN]; int deal(int x, int y)

  • poj 2486 Apple Tree (树形dp) 2013-08-29

    Apple Tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6674 Accepted: 2208 Description Wshxzt is a lovely girl. She likes apple very much. One day HX takes her to an apple tree. There are N nodes in the tree. Each node has an amount of

  • ural 1018 Binary Apple Tree 2013-10-04

    1018. Binary Apple Tree Time limit: 1.0 second Memory limit: 64 MB Let's imagine how apple tree looks in binary computer world. You're right, it looks just like a binary tree, i.e. any biparous branch splits up to exactly two new branches. We will en

  • URAL 1018 Binary Apple Tree 简单树形背包 2014-12-08

    Description Let's imagine how apple tree looks in binary computer world. You're right, it looks just like a binary tree, i.e. any biparous branch splits up to exactly two new branches. We will enumerate by integers the root of binary apple tree, poin

  • HDU 4786 Fibonacci Tree 2012-12-09

    Problem Description   Coach Pang is interested in Fibonacci numbers while Uncle Yang wants him to do some research on Spanning Tree. So Coach Pang decides to solve the following problem:   Consider a bidirectional graph G with N vertices and M edges.

  • HDU 3333 Turing Tree(离线线段树) 2014-04-24

    Problem Description After inventing Turing Tree, 3xian always felt boring when solving problems about intervals, because Turing Tree could easily have the solution. As well, wily 3xian made lots of new problems about intervals. So, today, this sick t

Copyright (C) quwantang.com, All Rights Reserved.

趣玩堂 版权所有 京ICP备15002868号

processed in 0.032 (s). 10 q(s)