hdu 4112 Break the Chocolate(数学函数)
来源:互联网 发布:数据透视表常用快捷键 编辑:程序博客网 时间:2024/06/06 03:20
Break the Chocolate
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 469 Accepted Submission(s): 159
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.
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
21 1 32 2 2
Sample Output
Case #1: 2 2Case #2: 7 3
Source
2011 Asia ChengDu Regional Contest
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4112
分析:几个数学函数就能搞定了。。。
我居然弱弱的写了个模拟,数学弱爆了啊,求师傅T_T
#include<cstdio>#include<cmath>int main(){ __int64 n,m,k,t,cas=0; scanf("%I64d",&t); while(t--) { scanf("%I64d%I64d%I64d",&n,&m,&k); printf("Case #%I64d: %I64d %I64d\n",++cas,n*m*k-1,(__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)))); } return 0;}
- hdu 4112 Break the Chocolate(数学函数)
- HDU 4112 Break the Chocolate
- hdu-4112-Break the Chocolate
- hdu 4112 Break the Chocolate
- HDU - 4112 Break the Chocolate
- HDU - 4112 Break the Chocolate
- Break the Chocolate HDU
- HDU 4112 Break the Chocolate(模拟)
- hdu 4112 Break the Chocolate(模拟)
- HDU-#4112 Break the Chocolate(规律)
- hdu 4112 Break the Chocolate(水题)
- hdu 4112 Break the Chocolate 二分
- HDOJ 题目4112Break the Chocolate(数学)
- hdoj Break the Chocolate 4112 (数学规律题)
- [HDU 4112]Break the Chocolate[YY推公式]
- 学校1051 巧克力 ||HDU 4112 Break the Chocolate
- Reginal2011_Chengdu_B Break the Chocolate
- hdu4112: Break the Chocolate
- 语言基础——IO
- BSP
- 用C++设计一个不能被继承的类
- #include 和 在FileView中添加工程文件的使用和区别(简化ClassView)
- memcache在大型网站的应用策略
- hdu 4112 Break the Chocolate(数学函数)
- Bada学习- (三十)C++以及Flash应用开发流程之概述
- 使用Java反射机制反射Main函数------JDK1.4遗留的兼容性问题
- 链栈的实现
- 资治通鉴,卷五十七,蔡邕之败
- 程序正确性证明与并行程序设计
- 2046 骨牌铺方格
- 科研人员常用的十八大学术搜索引擎
- Eclipse中显示line number