3904 - Tile Code Asia - Seoul - 2007/2008

3904 - Tile Code
Asia - Seoul - 2007/2008
PDF Submit Ranking

 

The city of Songpa is now carrying out a project to build a bicycle transportation system called 鈥榞reen Songpa.鈥?By the end of this year, citizens and visitors alike will be able to pick up and drop off bicycles throughout the city. Recently, it was decided to attach a number tag to each bicycle for management use. The bicycles will be under control of the city鈥檚 traffic system.

The number tag contains a tile code of length n , which consists of 1×2 , 2×1 , and 2×2 tiles placed on a n rectangular plate in a way that every cell of the plate is covered by exactly one tile. The plate is divided into 2n cells of size 1×1 . Of course, no two tiles are allowed to overlap each other. The 2×5 plate and a tile code of length 5 are shown in Figures 1 and 2, respectively. The code will always be read from left to right. However, there is no distinction between the top side and the bottom side of the code. The code may be turned upside down. The code shown in Figure 3 is essentially the same code as in Figure 2.

 

/epsfbox{p3904.eps}

Given a positive integer n , the project director Dr. Yang wants to know how many tile codes of length n there are, that is, the number of ways to place the three kinds of tiles into a n rectangular plate subject to the above conditions. Write a program that can help him.

 

 

Your program is to read from standard input. The input consists of T test cases. The number of test cases T is given in the first line of the input. Each test case is given in a single line, which contains a positive integer n , 3$ /le$n$ /le$30 .

 

 

Your program is to write to standard output. Print exactly one line for each test case. The line should contain the number of tile codes of length n .

 

 

 

2 
3 
4

 

 

 

3 
8

 


Seoul 2007-2008

 

 

 

#include<stdio.h>
int main()
{
    int a[50],b[50];
    b[0]=0;
    b[1]=1;
    b[2]=3;
    for(int i=3;i<=30;i++)  b[i]=b[i-1]+b[i-2]*2;
    for(int i=1;i<=30;i++)
    {
        if(i&1)  a[i]=b[i/2];
        else a[i]=b[i/2]+b[i/2-1]*2;
    }

//上面的推理就不说了,因为镜面反射是除以2,但是对称的那部分只有1份,所以先加上这份,再除以2
    int T;
    scanf("%d",&T);
    while(T--)
    {
         int x;
         scanf("%d",&x);
         printf("%d/n",(a[x]+b[x])/2);
    }
    return 0;
}

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值