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