规律题:

  

#include<stdio.h>
#include<math.h>
#define eps 1e-8
int main()
{
int _case;
int n,m,k,i;
__int64 ans1;
int ans2,ans;
scanf("%d",&_case);
for(i=;i<=_case;i++)
{
scanf("%d%d%d",&n,&m,&k);
printf("Case #%d: ",i);
ans1=(__int64)n*m*k-;//
ans=; ans2=log((double)n)/log();
ans+=ans2;
if(log((double)n)/log()-ans2>eps)ans++; ans2=log((double)m)/log();
ans+=ans2;
if(log((double)m)/log()-ans2>eps)ans++; ans2=log((double)k)/log();
ans+=ans2;
if(log((double)k)/log()-ans2>eps)ans++; printf("%I64d %d\n",ans1,ans);
}
return ;
}
#include<stdio.h>
#include<math.h>
int main()
{
int t,T,n,m,k,ans2;
__int64 ans1;
scanf("%d",&T);
for(t=;t<=T;t++)
{
scanf("%d%d%d",&n,&m,&k);
ans1=(__int64)n*m*k-;
ans2=(ceil(log(n*1.0)/log(2.0))+ceil(log(m*1.0)/log(2.0))+ceil(log(k*1.0)/log(2.0)));
printf("Case #%d: %I64d %d\n",t,ans1,ans2);
}
return ;
}
C语言有以下几种取整方法: 
1、直接赋值给整数变量。如:
int i = 2.5; 或 i = (int) 2.5;
这种方法采用的是舍去小数部分
2、C/C++中的整数除法运算符“/”本身就有取整功能(int / int),但是整数除法对负数的取整结果和使用的C编译器有关。
3、使用floor函数。floor(x)返回的是小于或等于x的最大整数。如:
floor(2.5) = 2
floor(-2.5) = -3
4、使用ceil函数。ceil(x)返回的是大于x的最小整数。如:
ceil(2.5) = 3
ceil(-2.5) = -2
floor()是向负无穷大舍入,floor(-2.5) = -3;ceil()是向正无穷大舍入,ceil(-2.5) = -2。

hdu 4112 Break the Chocolate(ceil floor)的更多相关文章

  1. hdu 4112 Break the Chocolate(乱搞题)

    题意:要把一块n*m*k的巧克力分成1*1*1的单元,有两种操作方式:1,用手掰(假设力量无穷大),每次拿起一块,掰成两块小的:2,用刀切(假设刀无限长),可以把多块摆在一起,同时切开.问两种方式各需 ...

  2. HDU - 4112 Break the Chocolate(规律)

    题意:有一块n*m*k的巧克力,最终需要切成n*m*k个1*1*1的块,问用以下两种方法最少掰多少次能达到目的: 1.用手掰:每次只能拿出一块来掰:2.用刀切:可以把很多已经分开的块摞在一起一刀切下来 ...

  3. hdu 4112 Break the Chocolate 贪心

    Break the Chocolate Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem. ...

  4. HDU 3131 One…Two…Five! (暴力搜索)

    题目链接:pid=3131">HDU 3131 One-Two-Five! (暴力搜索) 题意:给出一串数字,要求用加,减,乘,除(5/2=2)连接(计算无优先级:5+3*6=8*6= ...

  5. HDU 5783 Divide the Sequence(数列划分)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  6. HDU 5795 A Simple Nim(简单Nim)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  7. HDU 3496 Watch The Movie(看电影)

    HDU 3496 Watch The Movie(看电影) Time Limit: 1000MS   Memory Limit: 65536K [Description] [题目描述] New sem ...

  8. HDU 5224 Tom and paper(最小周长)

    HDU 5224 Tom and paper(最小周长) Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d &a ...

  9. HDU 5868 Different Circle Permutation(burnside 引理)

    HDU 5868 Different Circle Permutation(burnside 引理) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=586 ...

随机推荐

  1. iis7应用程序池自动关闭问题解决

    解决: 应用程序池启动32位应用程序 设置托管管道为集成 (仍然有问题) 图片:123.png 访问网站之前 应用程序池是开启的 访问后 网页报503 service unavailable应用程序池 ...

  2. MS Chart-按照数据库的最大最小时间设置X轴label.

    核心代码: Chart1.ChartAreas[0].AxisX.Interval = (Front_Max - Front_Min).Days / 2; Chart1.ChartAreas[0].A ...

  3. ALTERA MAX10官方评估板,新鲜出炉!

    刚刚拿到骏龙提供的ALTERA MAX10官方评估板,还热乎呢,呵呵!赶紧跟大家分享一下 板子很简单,把IO口都扩展出来了,其他功能基本上没有. FPGA型号是10M08SAE144C8GES,144 ...

  4. UIImageView swift

    // // ViewController.swift // UILabelTest // // Created by mac on 15/6/23. // Copyright (c) 2015年 fa ...

  5. QT对话框设计

    软件和系统:QTcreator5.7,win8.1 1. 首先新建项目,选择application中的Qt widgets application. 2. 创建类Dialog,选择QDialog作为基 ...

  6. Understanding Convolutions【转】

    Understanding Convolutions In a previous post, we built up an understanding of convolutional neural ...

  7. 详解使用CSS3绘制矩形、圆角矩形、圆形、椭圆形、三角形、弧

    1.矩形 绘制矩形应该是最简单的了,直接设置div的宽和高,填充颜色,效果就出来了. 2.圆角矩形 绘制圆角矩形也很简单,在1的基础上,在使用css3的border-radius,即可. 3.圆 根据 ...

  8. android开发支付宝接口开发流程(密钥篇)

    参考博客:http://blog.it985.com/12276.html 官方下载地址:http://download.alipay.com/public/api/base/WS_MOBILE_PA ...

  9. 从URL中获取搜索关键字

    public string GetSearchKeyWords(string strQuery) { string result = ""; string pattern = &q ...

  10. cygwin and its host machine

    Senario 本来我是想要修改下 machine name 在Ubuntu中的步骤是这样的 1 sudo hostname newMechineName 2 sudo vi /etc/hostnam ...