Nyoj 252 01 strings (Fibonacci sequence variants)

Source: Internet
Author: User

01 String time limit:MS | Memory limit:65535 KB Difficulty:2
Describe

ACM's ZYC is studying 01 strings, and he knows the length of some 101 strings, but he wants to know how many 01 strings of this length do not contain the "11" substring, and he wants you to help him.

Note: The length of the 01 string is 2 o'clock, there are 3 kinds: 00,01,10.

Input
the first line has an integer n (0<n<=100), which indicates that there are n sets of test data;
Then there are n rows, each line having an integer m (2<=m<=40), representing the length of the 01 string;
Output
The
output does not contain the "11" substring of this length of 01 string total number of, one row.
Sample input
223
Sample output
35

1#include <iostream>2 using namespacestd;3 inta[ -];4 intMain ()5 {6a[0]=1, a[1]=2; a[2]=3;7      for(intI=3; i<= -; i++)8a[i]=a[i-1]+a[i-2];9     intN,n;cin>>N;Ten      while(n--) One     { ACin>>N; -cout<<a[n]<<Endl; -     } the     return 0; -}

Nyoj 252 01 strings (Fibonacci sequence variants)

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.