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
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?
For each test case, two integers N, M (1<=N, M<=100) are given in a line, which denote the size of the map.
2
2 2
3 3
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 (瞎搞)的更多相关文章
- HDU 4925 Apple Tree(推理)
HDU 4925 Apple Tree 题目链接 题意:给一个m*n矩阵种树,每一个位置能够选择种树或者施肥,假设种上去的位置就不能施肥,假设施肥则能让周围果树产量乘2.问最大收益 思路:推理得到肯定 ...
- 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 2222 Keywords Search(瞎搞)
Keywords Search Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others ...
- hdu 4786 Fibonacci Tree 乱搞 智商题目 最小生成树
首先计算图的联通情况,如果图本身不联通一定不会出现生成树,输出"NO",之后清空,加白边,看最多能加多少条,清空,加黑边,看能加多少条,即可得白边的最大值与最小值,之后判断Fibo ...
- HDU-4925 Apple Tree
http://acm.hdu.edu.cn/showproblem.php?pid=4925 Apple Tree Time Limit: 2000/1000 MS (Java/Others) ...
随机推荐
- java.lang.NoSuchMethodError:org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session
项目配置了spring 4.0.6.RELEASE 和hibernate4.2.0.Final ,出错原因是因为在Spring 3.1开始没有了HibernateDaoSupport类,而我的却Dao ...
- Spoj Query on a tree III
题目描述 给出N个点的一棵树(N-1条边),节点有白有黑,初始全为白 有两种操作: 0 i : 改变某点的颜色(原来是黑的变白,原来是白的变黑) 1 v : 询问1到v的路径上的第一个黑点,若无,输出 ...
- 【博弈论】【SG函数】【找规律】Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) E. Game of Stones
打表找规律即可. 1,1,2,2,2,3,3,3,3,4,4,4,4,4... 注意打表的时候,sg值不只与剩下的石子数有关,也和之前取走的方案有关. //#include<cstdio> ...
- CSS3:固定textarea文本域宽度
textarea在一些浏览器上可以被拖拉改变大小,为了保持美观,可以通过 CSS3 resize 属性禁掉 textarea{resize:none; //不允许用户调整元素大小}
- 学习Struts2.3
</pre>1.struts2.3核心jar包(若首次接触,可临时略过不看)大家能够到http://struts.apache.org/download.cgi#struts2014下载s ...
- SpringMVC学习记录(七)--拦截器的使用
SpringMVC的请求如以下这样的图所看到的: 能够看出全部的请求都要通过Dispatherservlet来接收,然后通过Handlermapping来决定使用哪个控制器,再依据ViewResolv ...
- Druid对比Hadoop
Druid对比Hadoop Hadoop 向世界证明, 花费很少的钱实现典型的解决方案, 将数据保存在一般的商用机器的数据仓库里是可行的. 当人们将自己的数据保存在Hadoop, 他们发现两个问题 ...
- Hadoop之Azkaban详解
工作流调度器azkaban1 为什么需要工作流调度系统 1)一个完整的数据分析系统通常都是由大量任务单元组成:shell脚本程序,java程序,mapreduce程序.hive脚本等 2)各任务单元之 ...
- android 开发者的个人博客集
1. http://stormzhang.com/posts.html //不少的好的工具与建议
- 转:http2基本中文翻译
https://github.com/fex-team/http2-spec/blob/master/HTTP2%E4%B8%AD%E8%8B%B1%E5%AF%B9%E7%85%A7%E7%89%8 ...