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> ...
随机推荐
- netif_receive_skb->__netif_receive_skb_core
在设备驱动收包之后,会通过netif_receive_skb将收取的包,按照注册的协议回调,传递到上层进行处理: /* 将skb传递到上层 */ static int __netif_receive_ ...
- MAC和PHY的区别 (转自http://www.cnblogs.com/feitian629/archive/2013/01/25/2876857.html)
一块以太网网卡包括OSI(开方系统互联)模型的两个层.物理层和数据链路层.物理层定义了数据传送与接收所需要的电与光信号.线路状态.时钟基准.数据编码和电路等,并向数据链路层设备提供标准接口.数据链路层 ...
- SQLserver连接本地服务器
1.打开SQLserver “连接到服务器” 2.服务器类型:数据库引擎 3.服务器名称:浏览更多->本地服务器->数据库引擎->选择本地服务器 4.身份验证:windows验证 5 ...
- javaScript-继承2种方式
1.组合继承 组合继承带来的问题很明细就是父类的构造函数会调用两次,如: function Person(name, age, sex) { this.name = name; this.age = ...
- Java多线程之赛跑游戏(含生成exe文件)
在JavaSE中,多线程是一个重要的内容. 我们要了解多线程的概念,就要先了解进程的概念:要了解进程的概念,就离不开操作系统的概念. 在一台正常运行的电脑中,计算机硬件(如CPU.内存.硬盘.网卡.显 ...
- IndexWriterConfig的各个配置项说明(转)
1.Analyzer:分析器 2.matchVersion:所用Lucene的版本 3.ramBufferSizeMB:随机内存 默认为16M. 用于控制buffer索引文档的内存上限,如果buffe ...
- socket编程——sockaddr_in结构体操作
sockaddr结构体 sockaddr的缺陷: struct sockaddr 是一个通用地址结构,这是为了统一地址结构的表示方法,统一接口函数,使不同的地址结构可以被bind() , connec ...
- tp总结
不知不觉学tp也快一个月了,虽然还处于一个仅仅只会使用的阶段,但毕竟算是我详细接触的第一个脚本框架,tp还是让我收获了许多. 废话不多说,先列出几个对于我这种新手来说tp新奇而实用的地方. 1.连贯操 ...
- MVC – 8.Razor 布局
8.1.@RenderBody() 8.2.多个"占位符":@RenderSection() 8.3.js合并 @Scripts.Render("~/bundles/js ...
- fastdfs5.11+centos7.2 按照部署(一)【转载】
1.绪论 最近要用到fastDFS,所以自己研究了一下,在搭建FastDFS的过程中遇到过很多的问题,为了能帮忙到以后搭建FastDFS的同学,少走弯路,与大家分享一下.FastDFS的作者淘宝资深架 ...