hdu4925Apple Tree

//n*m的果园 , 种一棵树,收获一个果实//在一个格子施肥 ,, 其旁边的果树收获的·果实翻倍//问最多能收获多少果实//交叉种树 , 则为最大#include<cstdio>#include<cstring>#include<iostream>using namespace std ;const int maxn = 110 ;int map[maxn][maxn] ;int dx[4] = {0 , 1 , 0 ,-1} ;int dy[4] = {1 , 0 , -1 , 0} ;int main(){int n , m ;int t ;scanf("%d" , &t) ;while(t–){cin>>n>>m ;memset(map , 0 , sizeof(map)) ;int ans = 0 ;for(int i = 1;i <= n;i++)for(int j = 1;j <= m;j++)if((i+j)%2 == 0){int sum = 0 ;for(int k = 0 ;k < 4;k++){int nx = i + dx[k] ;int ny = j + dy[k] ;if(nx >= 1 && nx <= n && ny >= 1 && ny <= m)sum++ ;}ans += (1<<sum) ;}cout<<ans<<endl ;}}

版权声明:本文为博主原创文章,未经博主允许不得转载。

朋友,旭日正在升起,每一份付出,

hdu4925Apple Tree

相关文章:

你感兴趣的文章:

标签云: