zoukankan      html  css  js  c++  java
  • 01串

    01串

    描述

    ACM的zyc在研究01串,他知道某一01串的长度,但他想知道不含有“11”子串的这种长度的01串共有多少个,他希望你能帮帮他。

    注:01串的长度为2时,有3种:00,01,10。

     
    输入
    第一行有一个整数n(0<n<=100),表示有n组测试数据; 随后有n行,每行有一个整数m(2<=m<=40),表示01串的长度;
    输出
    输出不含有“11”子串的这种长度的01串共有多少个,占一行。
    样例输入
    2
    2
    3
    
    样例输出
    3
    5

     
    #include <iostream>
    #include <iomanip>
    #include <algorithm>
    #include <vector>
    #include <list>
    #include <memory.h>
    #include <string>
    #include <math.h>
    using namespace std;
    int main()
    {
      int n;
      cin>>n;
      while(n--)
      {
          int m;
          cin>>m;
          int arr[50] = {0,0,3,5};
    
          for(int i=4;i<=m;i++)
          {
              arr[i] = arr[i-1] + arr[i-2];
          }
    
          cout<<arr[m]<<endl;
      }
    
         return 0;
    }
    
                
  • 相关阅读:
    Codeforces Round #274 (Div. 2)
    codeforces 477C
    ZOJ 3822 Domination
    Codeforces Round #271 (Div. 2)
    进程
    线程
    udp和tcp特点 实现文件上传
    面向对象补1
    socket基本语法和粘包
    网络编程
  • 原文地址:https://www.cnblogs.com/imwtr/p/4069543.html
Copyright © 2011-2022 走看看