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> ...
随机推荐
- 记一个多线程使用libevent的问题
前段时间使用libevent网络库实现了一个游戏服务器引擎,在此记录下其中遇到的一个问题. 我在设计服务器上选择把逻辑和网络分线程,线程之间通信使用队列.但是这样做会有个问题: 当逻辑线程想要主动的发 ...
- juery给所有ID属性相同的div绑定一个事件
案例: <div id="div1">内容</div> <div id="div1">内容</div> < ...
- 设计模式之笔记--命令模式(Command)
命令模式(Command) 定义 命令模式(Command),将一个请求封闭为一个对象,从而使你可以用不同的请求对客户进行参数化:对请求排除或记录请求日志,以及支持可撤销的操作. 类图 描述 Comm ...
- Python 中的闭包与装饰器
闭包(closure)是函数式编程的重要的语法结构.闭包也是一种组织代码的结构,它同样提高了代码的可重复使用性. 如果在一个内嵌函数里,对在外部函数内(但不是在全局作用域)的变量进行引用,那么内嵌函数 ...
- 《深入理解Java虚拟机》笔记--第三章 、垃圾收集器与内存分配策略
1960年诞生于MIT的Lisp是第一门真正使用内存动态分配和垃圾收集技术的语言. Java的垃圾收集(Garbage Collection)主要关注堆和方法区的内存回收. 在GC堆进行回收前,第一件 ...
- angular项目中使用angular-material2
Step 1: Install Angular Material and Angular CDK npm install --save @angular/material @angular/cdk n ...
- 杂乱的code
/*o(n)的堆化方法*/ void myjust(vector<int>& A,int i){ int l=i*2+1; int r=i*2+2; int minn=i; if( ...
- 域名 DNS命令——dig
dig命令详解 1.查看域名的A记录 # dig yahoo.com; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.e ...
- CNN基础
CNN一般结构 卷积层作用: 1) 提取不同维度的特征,组合不同维度特征,其本质是卷积核,因此,学习一个有效的总卷积核是训练卷积层主要工作 2)寻找不同位置,不同大小的特征 3) 根据卷积核参数计算上 ...
- JavaScript 中的原型(总则)
1. 一切函数都是对象 2. 一切对象都是由函数创建的,所有函数都是由Function创建的,每个函数都是一个Function对象. 3. 对象.__proto__ === 函数.prototype ...