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> ...
随机推荐
- stegsolve使用探究
应该也不是工具的问题吧,更多的是图片.但是不知道咋取就写工具了. 比如:http://ctf5.shiyanbar.com/stega/chromatophoria/steg.png 我在想为毛要选择 ...
- Ubuntu 17.10 用 apt 搭建 lamp 环境、安装 phpmyadmin、redis 服务+扩展、mysql 扩展、开启错误提示、配置虚拟主机
2018-02-24 13:50:30 更新: 个人喜欢相对原生又不太麻烦,所以用 apt 构建环境.不过,最近使用到现在记得出现过了 3 次 apache 或 mysql 服务器无法启动或无法连接的 ...
- 【SSH项目实战】脚本密钥的批量分发与执行【转】
[TOC] 前言 <项目实战>系列为<linux实战教学笔记>第二阶段内容的同步教学配套实战练习,每个项目循序衔接最终将组成<Linux实战教学笔记>第二阶段核心教 ...
- u-boot引导内核过程
目标板:2440 u-boot引导内核启动时,传入内核的参数为bootcmd=nand read.jffs2 0x30007FC0 kernel; bootm 0x30007FC0 一.nand re ...
- python模块之cx_Oracle
安装cx_Oracle wget http://download.oracle.com/otn/linux/instantclient/122010/instantclient-basic-linux ...
- jstat分析JVM内存
zabbix: Jstat:gcutil:Old space utilization(%) S0 — Heap上的 Survivor space 0 区已使用空间的百分比S1 — Heap上的 S ...
- 二、python框架相关知识体系
Django框架 1.django框架.flask框架和Tornado框架的区别? django框架,内置组件多,自身功能强大,是一个大而全的框架,ORM.Admin.中间件.Form.ModelFr ...
- 查看loadrunner运行日志
查看loadrunner运行日志 日志分两种 1.在VUGEN中运行后的日志 2.在controller中运行后的日志日志设置分两步: 1.首先,在VUGEN或controller中run-tim ...
- oracle创建简单的包
--规范 create or replace package test_pkg is --test_pkg为包名 procedure showMessage; --声明一个过程 function my ...
- 将 sublime test3 添加到鼠标右键的方法
将 sublime test3 添加到鼠标右键的方法 将 sublime_addright.inf 文件放到 sublime text 安装目录进行安装即可. 文件名:sublime_addright ...