HDU-4112 Break the Chocolate

Source: Internet
Author: User

HDU-4112 Break the Chocolate

Problem Description
Benjamin is going to host a party fZ copyright · Fair "http://www.bkjia.com/kf/ware/vc/" target = "_ blank" class = "keylink"> Accept + CkFzIEJlbmphbWluIGlzIG9ubHkgYSA = "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 your 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.
InputThe first line contains an integer T (1 <= T <= 10000), indicating the number of test cases.
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.
OutputFor each test case in the input, print one line: "Case # X: a B", where X is the test case number (starting with 1 ), A and B are the minimum numbers of steps to break the chocolate into N Á ám ¡ák unit-size pieces with bare hands and knife respectively.
Sample Input
21 1 32 2 2

Sample Output
Case #1: 2 2Case #2: 7 3
Â Ò â £° ø ämáám⢠µ % ***************************************************** ó{μ ¶ çá Å É 1*1*1 µäð Ç çé ¿Ë ááá ~ö± Ð × ************************************** Ó µ μ ¶ çá £;******%²» ****************************************************

Ë ¼  · £° ê µ µä» ° £;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ¿É Ò Ô ¶ à ¿é» Ç £  £ Ç £? £;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ), · ö± languií~~~~~à ***********************************************************

#include 
 
  #include 
  
   #include #include 
   
    #include 
    
     typedef long long ll;using namespace std;int main() {int t, n, m, k, cas = 1;scanf("%d", &t);while (t--) {scanf("%d%d%d", &n, &m, &k);ll ans = 1ll * n * m * k;int cnt = 0;cnt += ceil(1.0 * log(n) / log(2));cnt += ceil(1.0 * log(m) / log(2));cnt += ceil(1.0 * log(k) / log(2));printf("Case #%d: ", cas++);cout << ans-1 << " " << cnt << endl;;}return 0;}
    
   
  
 




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.