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.

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.

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


int main()
	__int64 n,m,k,ans1,ans2,t,T;
		printf("Case #%I64d: %I64d %I64d\n",t,ans1,ans2);
	return 0;

hdu 4112 2011 ACM成都现场赛B

做完这道题让我深刻理解了log的使用,尽管我没有用它来写,把边长除以二再除以二一直除到一为止,就相当于log(2 底 边长). #include #include using namespace s...
  • a402630999
  • a402630999
  • 2012年01月18日 11:03
  • 1212

2011ACM成都赛区现场赛B题 (水题) (SPOJ9935)

水题,看了代码大家都明白的。 #include using namespace std; int tt; long long a,b,c,ans; int main() { scanf...
  • lencle
  • lencle
  • 2011年11月08日 23:21
  • 1288

【水题】2011 Asia ChenDu Regional Contest 成都现场赛 hdu 4112

水题,手切的次数是固定的,n*m*k-1,刀切最小是每条边长取2的对数,再ceil一下,相当于每次对折一样。 #include #include #include #include ...
  • leolin_
  • leolin_
  • 2011年11月09日 15:25
  • 977

2016 ICPC 大连站解题报告

  • woshirenNo01
  • woshirenNo01
  • 2016年11月06日 17:02
  • 780

2016ACM/ICPC亚洲区青岛站 ABC题题解

2016ACM/ICPC亚洲区青岛站 ABC题题解
  • ly59782
  • ly59782
  • 2016年11月20日 13:34
  • 785

B - Break the Chocolate HDU - 4112

题目链接:点击打开链接 题目大意:将一块N*M*K的巧克力分解成1*1*1的大小块,按照手工分和用刀切两种方式,问分别最少需要多少步? 手工的方法直接体积减一便是答案,而刀切的方法找规律,一个数一...
  • qq_38158040
  • qq_38158040
  • 2017年07月25日 09:49
  • 74

2011ACM成都赛区现场赛E题 (2-sat) (SPOJ9939)

这是我最痛心的一道题,就是少了四句话,忘了加上矛盾而已,导致了我们队的滑铁卢。想想我还是算擅长图论的,这么典型的2-sat题还不过,真的很不应该,面壁…… #include #include ...
  • lencle
  • lencle
  • 2011年11月08日 23:24
  • 1449

【HDU 5980 Find Small A】+ 2016ACM/ICPC亚洲区大连站-重现赛(感谢大连海事大学)

Find Small A Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) T...
  • WYK1823376647
  • WYK1823376647
  • 2016年11月12日 17:09
  • 432

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

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

2011ACM 成都现场 I题

哎 自己真是弱爆了,模拟题都搞不定。。 少了一个语句,回来加上就A了 太遗憾了 #include #include #include #include #in...
  • dingyaguang117
  • dingyaguang117
  • 2011年11月08日 19:46
  • 875
您举报文章:HDU 4112 2011ACM成都现场赛B