HRBUST1200-装修

装修
Time Limit: 1000 MSMemory Limit: 65536 K
Total Submit: 707(385 users)Total Accepted: 435(356 users)Rating: Special Judge: No
Description
hero为了能顺利娶princess ,花了血本,买了个房子,现在决定装修。房子的长度为n米,宽度为3米,现在我们有2种地砖,规格分别是1米×1米,2米×2米,如果要为该教室铺设地砖,请问有几种铺设方式呢?
Input
输入数据首先包含一个正整数C,表示包含C组测试用例,然后是C行数据,每行包含一个正整数n(1<=n<=30),表示教室的长度。
Output
对于每组测试数据,请输出铺设地砖的方案数目,每个输出占一行。
Sample Input
2
2
3
Sample Output
3
5
Author
王勇


解题思路:简单dp

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define LL long long
const int INF=0x3f3f3f3f;

int n;
LL a[40];

void init()
{
    a[1]=1,a[2]=3;
    for(int i=3;i<=30;i++)
        a[i]=a[i-1]+2*a[i-2];
}

int main()
{
    init();
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        printf("%lld\n",a[n]);
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值