hdu 4112 Break the Chocolate(乱搞题)
题意:要把一块n*m*k的巧克力分成1*1*1的单元,有两种操作方式:1,用手掰(假设力量无穷大),每次拿起一块,掰成两块小的;2,用刀切(假设刀无限长),可以把多块摆在一起,同时切开。问两种方式各需多少次操作才能完成任务。
分析:用手掰很明显是(n*m*k-1)次操作。用刀切注意不是((n-1)+(m-1)+(k-1))次操作,这只是不动原巧克力的操作数。举个例子:1*1*4的巧克力,用刀切,按上面说的要3次操作,实际上只需2次。所以不管是长宽高,都只需要[log2n](或m,k)次操作。
注意:数据范围上限是2000,n*m*k后超出231的范围,__int64
#include<cstdio>
#include<cstring>
#include<algorithm>
#define lld __int64
using namespace std; lld ans; void Num(int x)
{
while(x>)
{
if(x%)
x=x/+;
else
x=x/;
ans++;
}
return ;
} int main()
{
int T;
lld n,m,k;
scanf("%d",&T);
for(int cnt=;cnt<=T;cnt++)
{
scanf("%I64d%I64d%I64d",&n,&m,&k);
ans=;
Num(n);
Num(m);
Num(k);
printf("Case #%d: %I64d %I64d\n",cnt,n*m*k-,ans);
}
return ;
}
hdu 4112 Break the Chocolate(乱搞题)的更多相关文章
- hdu 4112 Break the Chocolate 贪心
Break the Chocolate Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem. ...
- 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的巧克力,最终需要切成n*m*k个1*1*1的块,问用以下两种方法最少掰多少次能达到目的: 1.用手掰:每次只能拿出一块来掰:2.用刀切:可以把很多已经分开的块摞在一起一刀切下来 ...
- CF_402C Searching for Graph 乱搞题
题目链接:http://codeforces.com/problemset/problem/402/C /**算法分析: 乱搞题,不明白题目想考什么 */ #include<bits/stdc+ ...
- codeforces 664B B. Rebus(乱搞题)
题目链接: B. Rebus time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- HDU 4923 Room and Moor(瞎搞题)
瞎搞题啊.找出1 1 0 0这样的序列,然后存起来,这样的情况下最好的选择是1的个数除以这段的总和. 然后从前向后扫一遍.变扫边进行合并.每次合并.合并的是他的前驱.这样到最后从t-1找出的那条链就是 ...
- codeforces 653C C. Bear and Up-Down(乱搞题)
题目链接: C. Bear and Up-Down time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- codeforces 669D D. Little Artem and Dance(乱搞题)
题目链接: D. Little Artem and Dance time limit per test 2 seconds memory limit per test 256 megabytes in ...
- HDU 4409 Family Name List --乱搞、LCA
题意: 给出一些名字,名字间有父子关系,有三种操作: 1.按祖先到后代,兄弟间按字典序由小到大排序,然后输出 2.求某个节点的兄弟节点有多少个,包括自己(注意,根节点的兄弟节点是1) 3.求节点a和b ...
随机推荐
- Java android DES+Base64加密解密
服务器与客户端加密解密传输, 中间遇到各种坑,客户端无论用AES还是DES解密时都会出现错误,后来才看到好多人说要用AES/DES加完密后还要BASE64加密,照做时发现android和java的Ba ...
- A/B Testing with Practice in Python (Part Two)
This is the second part of A/B testing notes, which contains the practical issues and alternatives o ...
- 由"软件是干什么的"引发的思考
自工作以来,都只在进行模块的开发,很少站在整个项目的角度思考过.甚至,自己开发的软件,自己都没有去用过,包括开发的一些APP,都没有下载来认真体验过.思考过.却对自己手机上那些用过的A ...
- Codeforces 1028E. Restore Array
题目直通车:http://codeforces.com/problemset/problem/1028/E 解法:设原数组为ar[],求ar中的最大值的下标ins,依次向前遍历一遍,每一个答案值都为前 ...
- JD
General Description: The role is responsible for China COE Operations Team’s data and cost analysis, ...
- iframe和response.sendRedirect()跳转到父页面的问题
在项目中,因为为了给页面分层次,就使用了 内嵌iframe 的分了三个框.在子页面进行操作的时候,如果session超时,就要被拦截器拦截重新回到首页进行登录,但是在sub页 面 ,进行操作的时候,如 ...
- idea点击RUN启动报错: Broken configuration due to unavailable plugin or invalid configuration dat
今天照常打开idea,突然发现之前的启动配置出问题了,随后报了一个这个错: Run Configuration Error: Broken configuration due to unavailab ...
- 五. 面向对象高级特性6. Java 泛型
我们知道,使用变量之前要定义,定义一个变量时必须要指明它的数据类型,什么样的数据类型赋给什么样的值. 假如我们现在要定义一个类来表示坐标,要求坐标的数据类型可以是整数.小数和字符串,例如: x = 1 ...
- Intent创建Activity
1,布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android ...
- Redis(二)linux下redis安装
上篇讲解了redis在windows下的安装,接下来看看在linux下如何安装redis(纯菜鸟入门级别)? (1)redis的下载及编译 这里,首先进入存放文件目录(我的云服务器的是:cd /jel ...