2015 Nanyang Ccpc L-huatuo ' s Medicine water problem

Source: Internet
Author: User
Tags cas

L-huatuo ' s Medicine

Time Limit:1 Sec

Memory limit:256 MB

Topic Connection

No

Description



Huatuo was a famous doctor. He use identical bottles to carry the medicine. There is different types of medicine. Huatuo put medicines into the bottles and chain these bottles together.

However, there was a critical problem. When Huatuo arrived the patient's home, he took the chain out of its bag, and he could not recognize which bottle contains Which type of medicine, but he remembers the order of the bottles on the chain.

Huatuo has he own solution to resolve this problem. When he need to bring 2 types of medicines, e.g. A and B, he would put a into one bottle and put B into the bottles. Then he'll chain the bottles in the order of-b-a-b-. In this to, when he arrived the patient's home, he knew the bottle in the middle are medicine A and the bottle on Sides is medicine B.

Now your need to help Huatuo to work out what's the minimal number of bottles needed if he want to bring N types of medicin E.



Inputfor each test case, output one line containing case #x: Y, where X was the test Case number (starting from 1) and Y-is The minimal number of bottles Huatuo needed. OutputFor each test case, an output one line containing case #x:, where x is the test Case number (starting from 1). Then the output 4 lines with 4 characters each. Indicate the recovered board.Sample Input
1
2

Sample Output

Case #1:3
HINT

Test instructions

Hua Tuo has n kinds of medicine, let you constitute a shortest chain, he can in the dark to find the medicine they want to find

Exercises

Symmetry is good, for example: d-c-b-a-b-c-d

So the answer 2n-1

Code:

#include <iostream>#include<stdio.h>using namespacestd;intMain () {intT;SCANF ("%d",&t);  for(intCAS =1; CAs <= T;cas + +)    {        intN;SCANF ("%d",&N); printf ("Case #%d:%d\n"Cas2*n-1); }}

2015 Nanyang Ccpc L-huatuo ' s Medicine water problem

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.