hdu 4112 Break the Chocolate 贪心
Break the Chocolate
Time Limit: 20 Sec Memory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=4112
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
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
Sample Input
Sample Output
HINT
题意
有两种切法,一种是一次切一块,一种是一次可以切多块,然后问你在两种情况下,最少切多少下
题解:
第一种就毫无疑问,就是 a*b*c-1,第二种脑补一下,很显然是二分切
然后小心爆int,然后就好了
代码:
- //qscqesze
- #include <cstdio>
- #include <cmath>
- #include <cstring>
- #include <ctime>
- #include <iostream>
- #include <algorithm>
- #include <set>
- #include <vector>
- #include <sstream>
- #include <queue>
- #include <typeinfo>
- #include <fstream>
- #include <map>
- #include <stack>
- typedef long long ll;
- using namespace std;
- //freopen("D.in","r",stdin);
- //freopen("D.out","w",stdout);
- #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
- #define maxn 50051
- #define mod 10007
- #define eps 1e-9
- int Num;
- char CH[];
- //const int inf=0x7fffffff; //нчоч╢С
- const int inf=0x3f3f3f3f;
- /*
- inline void P(int x)
- {
- Num=0;if(!x){putchar('0');puts("");return;}
- while(x>0)CH[++Num]=x%10,x/=10;
- while(Num)putchar(CH[Num--]+48);
- puts("");
- }
- */
- inline ll read()
- {
- ll x=,f=;char ch=getchar();
- while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
- while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
- return x*f;
- }
- inline void P(int x)
- {
- Num=;if(!x){putchar('');puts("");return;}
- while(x>)CH[++Num]=x%,x/=;
- while(Num)putchar(CH[Num--]+);
- puts("");
- }
- //**************************************************************************************
- int deal(int x)
- {
- int cnt=;
- while()
- {
- if(<<cnt>=x)
- return cnt;
- cnt++;
- }
- }
- int main()
- {
- //freopen("test.txt","r",stdin);
- int t=read();
- for(int cas=;cas<=t;cas++)
- {
- ll a,b,c;
- a=read(),b=read(),c=read();
- printf("Case #%d: %lld %lld\n",cas,a*b*c-,deal(a)+deal(b)+deal(c));
- }
- }
hdu 4112 Break the Chocolate 贪心的更多相关文章
- hdu 4112 Break the Chocolate(ceil floor)
规律题: #include<stdio.h> #include<math.h> #define eps 1e-8 int main() { int _case; int n,m ...
- hdu 4112 Break the Chocolate(乱搞题)
题意:要把一块n*m*k的巧克力分成1*1*1的单元,有两种操作方式:1,用手掰(假设力量无穷大),每次拿起一块,掰成两块小的:2,用刀切(假设刀无限长),可以把多块摆在一起,同时切开.问两种方式各需 ...
- HDU - 4112 Break the Chocolate(规律)
题意:有一块n*m*k的巧克力,最终需要切成n*m*k个1*1*1的块,问用以下两种方法最少掰多少次能达到目的: 1.用手掰:每次只能拿出一块来掰:2.用刀切:可以把很多已经分开的块摞在一起一刀切下来 ...
- Break the Chocolate(规律)
Break the Chocolate Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- Codeforces Round #304 (Div. 2) Break the Chocolate 水题
Break the Chocolate Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/546/ ...
- hdu 4825 Xor Sum(trie+贪心)
hdu 4825 Xor Sum(trie+贪心) 刚刚补了前天的CF的D题再做这题感觉轻松了许多.简直一个模子啊...跑树上异或x最大值.贪心地让某位的值与x对应位的值不同即可. #include ...
- HDU 5813 Elegant Construction (贪心)
Elegant Construction 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5813 Description Being an ACMer ...
- HDU 3697 Selecting courses(贪心)
题目链接:pid=3697" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=3697 Prob ...
- hdu 1257 && hdu 1789(简单DP或贪心)
第一题;http://acm.hdu.edu.cn/showproblem.php?pid=1257 贪心与dp傻傻分不清楚,把每一个系统的最小值存起来比较 #include<cstdio> ...
随机推荐
- Test plan
Options for Test Strategy: 1. Regular test: all the planned test cases will be executed 2. Extented ...
- MySQL数据库设置为只读及测试【转】
转自 mysql只读模式的设置方法与实验 - yumushui的专栏 - CSDN博客http://blog.csdn.net/yumushui/article/details/41645469 在M ...
- python模块之xlrd,xlwt,读写execl(xls,xlsx)
安装xlrd,xlwt pip install xlrd xlwt xlrd读取execl [环境ipython python2.7.5] import xlrd book = xlrd.open_w ...
- mysql delete 注意
mysql中You can't specify target table <tbl> for update in FROM clause错误的意思是说,不能先select出同一表中的某些值 ...
- linux 下配置文件目录/etc/sysconfig
/etc/sysconfig/目录详解 2010-06-19 11:12 6693人阅读 评论(1) 收藏 举报 桌面环境debugging防火墙serviceunix语言 /etc/sysconfi ...
- GPS 与 北斗 初步对比
一.脉冲 GPS每秒可获得一次卫星星历电文,秒脉冲的误差服从正态分布,锁住的可用卫星达到四颗以上时,授时脉冲的1精度在100 ns以内:当锁住的可用卫星少于四颗时,解算方程组的信息不够充分,授时精度将 ...
- postgresql 数据导入导出
[转] 分类: postgresql2013-06-09 10:21 2486人阅读 评论(0) 收藏 举报 一.导出数据库及具体表 1.导出数据库:方式一:pg_dump -U postgres ...
- Hadoop案例(七)MapReduce中多表合并
MapReduce中多表合并案例 一.案例需求 订单数据表t_order: id pid amount 1001 01 1 1002 02 2 1003 03 3 订单数据order.txt 商品信息 ...
- JavaScript 中的原型(总则)
1. 一切函数都是对象 2. 一切对象都是由函数创建的,所有函数都是由Function创建的,每个函数都是一个Function对象. 3. 对象.__proto__ === 函数.prototype ...
- html5弹性布局两则,有交互。
要开发一个后台管理框架,要求如下效果. 然后开始找各种弹性布局啊什么的,用了flex写了一个,但是觉得不好,首先是兼容,其次它会破坏掉里面子元素的一些css特性,为了不给自己找麻烦我还是用传统写法吧. ...