zoukankan      html  css  js  c++  java
  • 骨牌铺方格

    Problem Description
    在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数.
    例如n=3时,为2× 3方格,骨牌的铺放方案有三种,如下图:
     
    Input
    输入数据由多行组成,每行包含一个整数n,表示该测试实例的长方形方格的规格是2×n (0<n<=50)。
     
    Output
    对于每个测试实例,请输出铺放方案的总数,每个实例的输出占一行。
     
    Sample Input
    1 3 2
     
    Sample Output
    1 3 2
     
     
     
     
     
    #include<stdio.h>
    #include<stdlib.h>
    int main()
    {
        int n, a;
        int i, t;
        __int64 f[1000], j;
        while( ~scanf( "%d", &a ))
        {
               f[1] = 1;
               f[2] = 2;
               f[3] = 3;
               f[4] = 5;
               if( a == 1)
                 printf( "1\n" );
               else if( a == 2)
                 printf( "2\n" );
               else if( a == 3)
                 printf( "3\n" );
               else if( a == 4)
                 printf( "5\n" );
               else
               {
                  for( i = 5; i <= a; i++ )
                    j = f[i] = f[i-1] + f[i-2];
                      printf( "%I64d\n", j );
                }
        }
        system( "pause" );
        return 0;
    }
  • 相关阅读:
    运算放大器
    阻抗模型
    mysql优化
    tomcat调优
    jvm调优
    springboot使用
    deploy工程到nexus
    Spring data elasticsearch使用
    kibana使用
    笔记
  • 原文地址:https://www.cnblogs.com/zsj576637357/p/2252928.html
Copyright © 2011-2022 走看看