Summer warm-up D. Barcode Design

Source: Internet
Author: User

The ACM team is planning to ask for a special room for the school. But in order to prevent it from becoming a public room, FL recommends the use of credit card entry method, she designed a bar code, each corresponding to one. The bar code of this size 2*n is composed of the following three elements: 1*2, 2*1, 2*2 rectangular squares. But we also know that many people are prone to reverse the position of cards when they swipe. In order to avoid machine error handling, we think that the two barcodes are the same (the color of the picture is just for the convenience of explanation, do not consider).

FL now wants to know a problem, that is, with her barcode encoding, how many different barcodes can be used for a given length of n?

Input

Multiple sets of test data, one positive integer n (n≤28) per line, ending with n = 0 o'clock.

Output

Most with each set of data, first output "Case K:", where k represents the case number, then output a number, the number of barcodes available m (m not more than 231.)

Sample Input
123450
Sample Output
Case 1:1case 2:3case 3:3case 4:8case 5:12

2333 This problem and million Jie discussed out of the ^_^. To find recursion, divide n into odd or even odd cases, even two cases, recursion is divided between the middle of the discussion.
#include <stdio.h>#include<math.h>intd[ -],b[ -];intI,j,n;intMain () {d[0]=0; d[1]=1; d[2]=3; d[3]=5; b[0]=0; b[1]=1; b[2]=3; b[3]=1;  for(i=3; i<= -; i++) {D[i]=d[i-1]+d[i-2]*2; if(i%2!=0) {B[i]=d[(I-1)/2]; }        if(i%2==0) {B[i]=d[i/2]+d[(I-2)/2]*2; }} I=1;  while(SCANF ("%d", &n)!=eof&&n!=0) {J= (D[n]+b[n])/2; printf ("Case %d:%d\n", i++, J); }    return 0;}
View Code

Summer warm-up D. Barcode Design

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.