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) ...
随机推荐
- 复制对象 copy 与mutable copy
转载 : http://blog.csdn.net/u010962810/article/details/18887841 通过copy方法可以创建可变对象或不可变对象的不可变副本,对于不可 ...
- [BZOJ4650][NOI2016]优秀的拆分(SAM构建SA)
关于解法这个讲的很清楚了,主要用了设关键点的巧妙思想. 主要想说的是一个刚学的方法:通过后缀自动机建立后缀树,再转成后缀数组. 后缀数组功能强大,但是最令人头疼的地方是模板太难背容易写错.用这个方法, ...
- 【模拟】bzoj2295 【POJ Challenge】我爱你啊
#include<cstdio> #include<cstring> using namespace std; int n; char s[100001],table[]=&q ...
- Problem Q: 零起点学算法12——求2个日期之间的天数
#include<stdio.h> int main() { int a1,b1,c1,a2,b2,c2,s; scanf("%d-%d-%d",&a1,&am ...
- 爬取维基百科人物介绍,并使用pymysql存储到数据库
代码如下: from urllib.request import urlopen from bs4 import BeautifulSoup import re import datetime imp ...
- 自己做的javascript简易计算器
html <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF- ...
- 推荐10个免费的HTML编辑器
如果你想开发一个网站,你肯定想要一个很棒的HTML编辑器,一个好的编辑器可以让代码更加整齐格式化,前端显示也会更好,从而提升你的工作效率.下面就为开发者推荐10个免费的HTML编辑器,你可以尝试使用. ...
- Kubernetes master节点的高可用配置
了解Kubernetes架构都知道Master节点在整个集群中的位置,为了保证整个架构的高可用,Kubernetes提供了HA的架构,处于兴趣和对架构的进一步了解,我在自己的电脑实践以下. 环境: C ...
- JS中event.preventDefault()取消默认事件能否还原?
参考知乎讨论:https://www.zhihu.com/question/21891734
- t-SNE和LDA PCA的学习
t-SNE 可以看这篇文章: http://bindog.github.io/blog/2016/06/04/from-sne-to-tsne-to-largevis/ LDA可以看这篇文章: htt ...