HDU 4112 2011ACM成都现场赛B

原创 2011年11月09日 08:43:32

 

Break the Chocolate

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


Problem Description

Benjamin is going to host a party for his big promotion coming up.
Every party needs candies, chocolates and beer, and of course Benjamin has prepared some of those. But as everyone likes to party, many more people showed up than he expected. The good news is that candies are enough. And for the beer, he only needs to buy some extra cups. The only problem is the chocolate.
As Benjamin is only a 'small court officer' with poor salary even after his promotion, he can not afford to buy extra chocolate. So he decides to break the chocolate cubes into smaller pieces so that everyone can have some.
He have two methods to break the chocolate. He can pick one piece of chocolate and break it into two pieces with bare hand, or put some pieces of chocolate together on the table and cut them with a knife at one time. You can assume that the knife is long enough to cut as many pieces of chocolate as he want.
The party is coming really soon and breaking the chocolate is not an easy job. He wants to know what is the minimum number of steps to break the chocolate into unit-size pieces (cubes of size 1 × 1 × 1). He is not sure whether he can find a knife or not, so he wants to know the answer for both situations.
 

Input
The first line contains an integer T(1<= T <=10000), indicating the number of test cases.
Each test case contains one line with three integers N,M,K(1 <=N,M,K <=2000), meaning the chocolate is a cube of size N ×M × K.
 

Output
For each test case in the input, print one line: "Case #X: A B", where X is the test case number (starting with 1) , A and B are the minimum numbers of steps to break the chocolate into N × M × K unit-size pieces with bare hands and knife respectively.
 

Sample Input
2 1 1 3 2 2 2
 

Sample Output
Case #1: 2 2 Case #2: 7 3
 

Source
 
这是现场赛最简单的一道,很多牛校在很短的时间内就AC了
不过题目有个trick,就是要超int
 
我的代码:
#include<stdio.h>
#include<math.h>

int main()
{
	__int64 n,m,k,ans1,ans2,t,T;
	scanf("%I64d",&T);
	for(t=1;t<=T;t++)
	{
		scanf("%I64d%I64d%I64d",&n,&m,&k);
		ans1=n*m*k-1;
		ans2=(__int64)(ceil(log(n*1.0)/log(2.0))+ceil(log(m*1.0)/log(2.0))+ceil(log(k*1.0)/log(2.0)));
		printf("Case #%I64d: %I64d %I64d\n",t,ans1,ans2);
	}
	return 0;
}

相关文章推荐

2011ACM成都赛区现场赛H题 (非递归dfs) (hdu4118)

这题我在现场的时候用图论做超时,需要非递归dfs。 我维护了一个a数组记录结点的儿子数。 #include #include #include using namespace std; st...
  • lencle
  • lencle
  • 2011年11月10日 20:48
  • 3622

HDU 4119Isabella's Message2011成都现场赛I题(字符串模拟)

Isabella's Message Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other...
  • opm777
  • opm777
  • 2013年09月03日 23:11
  • 1626

HDU 4790 2013 ACM/ICPC 成都赛区现场赛 J. Just Random

hdu上模拟现场赛,做这题的时候很快出了想法,但是就是写错,一直wa, 不过再调试过程中应该算把这题理解地非常透彻了,感觉如果标解是和我思路一样的话,这题的难点就是细节处理,详细的分类讨论。其实后来想...

HDU 4790 Just Random (2013ACM/ICPC成都赛区现场赛J题)

 题意:给出两个区间[a,b]和[c,d],分别从这两个区间等概率的抽两个整数x,y,求(x+y)%p=m的概率。...

hdu 4473 Exam (2012ACM成都赛区现场赛J题)

题意:   定义  f(x) = { num | a*b| x } , 求 \sum { f(x) } , x 思路:   题目等价于求 a*b*c   假定 a ...

HDU4465_12年成都现场赛B——Candy

这是个很神奇的题目,可能比较考验水笔的

2011 ACM/ICPC 北京现场赛 B HouYi's secret

周日起床后看见QQ群消息说 bupt上有半同步北京现场赛试题,就进入看了下题,一共读了两个题 A和B(因为这两个题目当时就都提交的很多) A题不会做,有限制的生成树的这类知识好像还没有接触过。。。 ...
  • AC521
  • AC521
  • 2011年10月25日 10:37
  • 853

HDU 4082Hou Yi's secret2011北京现场赛B题(统计相似三角形个数)

Hou Yi's secret Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...
  • opm777
  • opm777
  • 2013年08月27日 16:40
  • 1200

2008年ACM-ICPC成都赛区现场赛题目

  • 2013年03月16日 13:25
  • 128KB
  • 下载

2014ACM Regional北京现场赛B题——HDU5113

2014ACM北京现场赛B题,构造法。题目:给出k种颜色,给n*m的格子染色,保证任意一个格子与周围格子颜色不同。...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:HDU 4112 2011ACM成都现场赛B
举报原因:
原因补充:

(最多只允许输入30个字)