hdu-4112-Break the Chocolate
来源:互联网 发布:windows bat date 编辑:程序博客网 时间:2024/05/22 17:27
题意:一块三维巧克力,手掰和刀切,最少几次,可分为n*m*k个单元块
题解:手掰,要有n*m*k个就要掰n*m*k下,当然,你掰下最后第二个的时候,最后一个就自然出现了,所以手掰是n*m*k-1个;
刀切, 可以上下叠起来切, 所以每一维的处理办法一样, 切一半+(一半的一半)+(一半的一半的一半)+..........,向上取整。
//
#include<iostream>#include<cstdio>using namespace std;__int64 f(__int64 n){int ans=0;while(n>1){ans++;if(n%2) n=(n/2)+1;else n/=2;}return ans;}int main(){__int64 T;cin>>T;for(int i=1; i<=T; i++){__int64 n,m,k;__int64 ans1=0, ans2=0;cin>>n>>m>>k;ans1 = n*m*k-1;ans2 = f(n)+f(m)+f(k);cout<<"Case #"<<i<<": "<<ans1<<" "<<ans2<<endl;}return 0;}
code
- 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(规律)
- hdu 4112 Break the Chocolate(水题)
- hdu 4112 Break the Chocolate 二分
- [HDU 4112]Break the Chocolate[YY推公式]
- 学校1051 巧克力 ||HDU 4112 Break the Chocolate
- Reginal2011_Chengdu_B Break the Chocolate
- hdu4112: Break the Chocolate
- HDOJ 题目4112Break the Chocolate(数学)
- hdoj Break the Chocolate 4112 (数学规律题)
- IE8中弹出窗口 隐藏地址栏
- vc api_获取系统信息和用户信息
- HDU/HDOJ 1242 Rescue 典型的迷宫广度优先搜索题
- Oracle 数据库表空间容量调整(表空间缩容脚本)脚本
- hdu 1213 并差集
- hdu-4112-Break the Chocolate
- 浣溪沙——纳兰性德
- hdu 1421 dp
- 关于java中<T>问题
- 一个servlet实现GPS坐标偏移接口功能
- hdu 1568 斐波那契性质
- Program perl 数据结构
- hdu 1587 简单完全背包
- hdu 3635 带权并查集