HDU 4112 Break the Chocolate(模拟)
来源:互联网 发布:数据融合算法 编辑:程序博客网 时间:2024/06/01 13:40
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4112
这个题目半想半猜
首先用手的话比较简单,直接分,先分那面都枚举一下
用刀的话就是一面一面的切
每面长取2的对数,如果是整数,那么就是本身,小数就向上取整
三面这样计算相加,也就是在刀切的时候是对数切割次数,如果有零头就要多切一次
#include <iostream>#include <string.h>#include <stdio.h>#include <algorithm>#include <cmath>using namespace std;#define LL __int64#define MIN(a,b) (a<b?a:b)LL n,m,k;int main(){ //cout<<"k:"<<log2(8)<<endl; int i,j,Case=0,t; LL hand,klife,now; double temp; scanf("%d",&t); while(t--){ scanf("%I64d%I64d%I64d",&n,&m,&k); if(m==1 && n==1 && k==1){ printf("Case #%d: %d %d\n",++Case,0,0); continue; } hand=klife=0; now=(m-1)+m*(n-1+n*(k-1)); hand=now; now=(m-1)+m*(k-1+k*(n-1)); hand=MIN(now,hand); now=(n-1)+n*(m-1+m*(k-1)); hand=MIN(now,hand); now=(n-1)+n*(k-1+k*(m-1)); hand=MIN(now,hand);; now=(k-1)+k*(n-1+n*(m-1)); hand=MIN(now,hand); now=(k-1)+k*(m-1+m*(n-1)); klife=0; //klife+=n-1+m-1+k-1; temp=log2(m*1.0); if(temp-(LL)temp==0) klife+=(LL)(temp); else klife+=(LL)(temp)+1; temp=log2(n*1.0); if(temp-(LL)temp==0) klife+=(LL)(temp); else klife+=(LL)(temp)+1; temp=log2(k*1.0); if(temp-(LL)temp==0) klife+=(LL)(temp); else klife+=(LL)(temp)+1; printf("Case #%d: %I64d %I64d\n",++Case,hand,klife); } return 0;}
- HDU 4112 Break the Chocolate(模拟)
- hdu 4112 Break the Chocolate(模拟)
- HDU-#4112 Break the Chocolate(规律)
- HDU 4112 Break the Chocolate
- hdu-4112-Break the Chocolate
- hdu 4112 Break the Chocolate
- HDU - 4112 Break the Chocolate
- HDU - 4112 Break the Chocolate
- Break the Chocolate HDU
- hdu 4112 Break the Chocolate(数学函数)
- hdu 4112 Break the Chocolate(水题)
- hdu 4112 Break the Chocolate 二分
- [HDU 4112]Break the Chocolate[YY推公式]
- 学校1051 巧克力 ||HDU 4112 Break the Chocolate
- HDOJ 题目4112Break the Chocolate(数学)
- hdoj Break the Chocolate 4112 (数学规律题)
- Break the Chocolate(推论题)
- Reginal2011_Chengdu_B Break the Chocolate
- WPF布局
- fmt标签国际化
- SQL2005对字符串进行MD5加密
- Jquery 表单验证插件资源整理
- SNMP测试
- HDU 4112 Break the Chocolate(模拟)
- Shell Script For MySQL Enterprise Backup Crontab Schedule
- Oracle 中 将多行列值按照顺序合并成单值输出(connect by)
- 黑马程序员_Java中的接口讲解
- c# 进程间通信
- javascrip中的继承
- PDF文档结构
- oracle 批量查询DDL
- oracle with 用法