Wuhan University of Science and Technology acm:1010:0 starting point algorithm 89--cow Story

Source: Internet
Author: User

Problem Description

There is a cow, which has a small cow at the beginning of each year. Each heifer starts its fourth year with a heifer. Please program implementation how many cows are there in the first n years?

Input

The input data consists of multiple test instances, one for each test instance, including an integer n (0<n<55), and the meaning of n as described in the topic.
N=0 indicates the end of the input data and does not handle it.

Output

For each test instance, output the number of cows in the nth year.
Each output occupies one row.

Sample Input
2450
Sample Output
246
HINT

1#include <stdio.h>2 intMain ()3 {4     intf[ -]={1,1,2,3},n,i;5      for(i=4;i< -; i++)6     {7f[i]=f[i-1]+f[i-3];8     }9      while(SCANF ("%d", &n)!=eof&&n!=0)Ten     { Oneprintf"%d\n", F[n]); A     } -     return 1; -}

Wuhan University of Science and Technology acm:1010:0 starting point algorithm 89--cow Story

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.