hdu5155---Harry And Magic Box

Harry And Magic Box

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 131    Accepted Submission(s): 64


Problem Description
One day, Harry got a magical box. The box is made of n*m grids. There are sparking jewel in some grids. But the top and bottom of the box is locked by amazing magic, so Harry can’t see the inside from the top or bottom. However, four sides of the box are transparent, so Harry can see the inside from the four sides. Seeing from the left of the box, Harry finds each row is shining(it means each row has at least one jewel). And seeing from the front of the box, each column is shining(it means each column has at least one jewel). Harry wants to know how many kinds of jewel’s distribution are there in the box.And the answer may be too large, you should output the answer mod 1000000007.
 

Input
There are several test cases.
For each test case,there are two integers n and m indicating the size of the box. 0n,m50 .
 

Output
For each test case, just output one line that contains an integer indicating the answer.
 

Sample Input
  
1 1 2 2 2 3
 

Sample Output
  
1 7 25
Hint
There are 7 possible arrangements for the second test case. They are: 11 11 11 10 11 01 10 11 01 11 01 10 10 01 Assume that a grids is '1' when it contains a jewel otherwise not.
 

Source
 

Recommend
heyang   |   We have carefully selected several similar problems for you:   5157  5156  5153  5152  5151

一开始想复杂了,想了个三维dp,dp[i][j][k]表示放了k个棋子,现在有i行j列是亮的
然后悲剧了半天还是没调出来

dp[i][j] 表示在前i行,每一行都亮,而一共有j列是亮的

考虑第i行放k个,亮t个
dp[i][j + t] = dp[i - 1][j] * C[m - j][t] * C[j][k - t]

/*************************************************************************
    > File Name: hdu5155.cpp
    > Author: ALex
    > Mail: 405045132@qq.com 
    > Created Time: 2015年01月03日 星期六 21时52分09秒
 ************************************************************************/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int mod = 1000000007;
long long dp[55][55];
long long C[55][55];

void Combine()
{
	memset (C, 0, sizeof(C));
	C[0][0] = 1;
	for (int i = 1; i <= 50; ++i)
	{
		C[i][0] = 1;
		for (int j = 1; j <= i; ++j)
		{
			if (i == j)
			{
				C[i][j] = 1;
			}
			else if (j == 1)
			{
				C[i][j] = i;
			}
			else
			{
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
				C[i][j] %= mod;
			}
//			printf("%d\n", C[i][j]);
		}
	}
}

int main()
{
	Combine();
	int n, m;
	while (~scanf("%d%d", &n, &m))
	{
		memset (dp, 0, sizeof(dp));
		dp[0][0] = 1;
		for (int i = 1; i <= n; ++i)
		{
			for (int j = 0; j <= m; ++j) //前i - 1行亮的列数
			{
				for (int k = 1; k <= m; ++k)//这一行放了k个
				{
					for (int t = 0; j + t <= m; ++t)//这一行亮t个
					{
						if (k - t < 0)
						{
							continue;
						}
						long long tmp = dp[i - 1][j] * C[m - j][t];
						tmp %= mod;
						tmp *= C[j][k - t];
						tmp %= mod;
						dp[i][j + t] += tmp;
						dp[i][j + t] %= mod;
					}
				}
			}
		}
		printf("%lld\n", dp[n][m]);
	}
	return 0;
}


下载方式:https://pan.quark.cn/s/b4d8292ba69a 在构建食品品牌的市场整合营销推广方案时,我们必须首先深入探究品牌的由来、顾客的感知以及市场环境。 此案例聚焦于一款名为“某饼干产品”的食品,该产品自1998年进入河南市场以来,经历了销售业绩的波动。 1999至2000年期间,其销售额取得了明显的上升,然而到了2001年则出现了下滑。 在先前的宣传活动中,品牌主要借助大型互动活动如ROAD SHOW来吸引顾客,但收效甚微,这揭示了宣传信息与顾客实际认同感之间的偏差。 通过市场环境剖析,我们了解到消费者对“3+2”苏打夹心饼干的印象是美味、时尚且充满活力,但同时亦存在口感腻、价位偏高、饼身坚硬等负面评价。 实际上,该产品可以塑造为兼具美味、深度与创新性的休闲食品,适宜在多种情境下分享。 这暗示着品牌需更精确地传递产品特性,同时消解消费者的顾虑。 在策略制定上,我们可考虑将新产品与原有的3+2苏打夹心进行协同推广。 这种策略的长处在于能够借助既有产品的声誉和市场占有率,同时通过新产品的加入,刷新品牌形象,吸引更多元化的消费群体。 然而,这也可能引发一些难题,例如如何合理分配新旧产品间的资源,以及如何保障新产品的独特性和吸引力不被既有产品所掩盖。 为了提升推广成效,品牌可以实施以下举措:1. **定位修正**:基于消费者反馈,重新确立产品定位,突出其美味、创新与共享的特性,减少消费者感知的缺陷。 2. **创新宣传**:宣传信息应与消费者的实际体验相契合,运用更具魅力的创意手段,例如叙事式营销,让消费者体会到产品带来的愉悦和情感共鸣。 3. **渠道选择**:在目标消费者常去的场所开展活动,例如商业中心、影院或在线平台,以提高知名度和参与度。 4. **媒体联...
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值