zoukankan      html  css  js  c++  java
  • HDOJ_ACM_Tiling_easy version

    Problem Description
    有一个大小是 2 x n 的网格,现在需要用2种规格的骨牌铺满,骨牌规格分别是 2 x 1 和 2 x 2,请计算一共有多少种铺设的方法。
     
    Input
    输入的第一行包含一个正整数T(T<=20),表示一共有 T组数据,接着是T行数据,每行包含一个正整数N(N<=30),表示网格的大小是2行N列。
     
    Output
    输出一共有多少种铺设的方法,每组数据的输出占一行。
     
    Sample Input
    3
    2
    8
    12
     
    Sample Output
    3
    171
    2731
     
     
    Code
    View Code
    Key Points
    what you should care about is just the formula f(n)=f(n-1)+2*f(n-2).
    for f(n), if you put the 2*1 card standing by its end, this is f(n-1), if you put the 2*1 cards by accross, this is f(n-2), besides you put the 2*2 card. Consequently, add together, you will the regular. 
  • 相关阅读:
    MySQL-多条件拼接语句
    MongoDB-C#驱动基本操作
    MongoDB-C#驱动帮助
    MongoDB-权限配置
    MongoDB-安装
    C#_实用
    提高C#代码质量-规范
    C#_Express-ickd接口
    Eclipse背景颜色修改
    Java中可变长参数的方法
  • 原文地址:https://www.cnblogs.com/chuanlong/p/2763244.html
Copyright © 2011-2022 走看看