The big flag-raising

   
   
In the Maritime University , there is a tradition that is big flag-raising . At 5:50 in the morning , wearing uniforms and lining up for each student is a big headache . In order to improve the efficiency of collection and save more sleep time .The school leadership decides to divide the specific area into N small areas of equal size.Now assume that we don’t consider the length of the queue .The small areas will be seen as a straight line. In order to look more orderly, students in each small area are required to wear the same uniform .The adjacent small area should not wear the same uniform.Moreover, the head area and the tail area can’t wear the same uniform.There are some phalanxes(each phalanx occupies one small area) dressed in the specific uniform (one of three given kinds of uniform), and we want to know how many different permutation solutions(Assume that the number of phalanxes waring each kind of uniform is a certain number)。
Input
   
   
The input will contain multiple test cases ,
Each case will only contain a number N(1 <= N <= 50).
 

Output
   
   
Output the answer in a line.
 

Sample Input
   
   
1 2
 

Sample Output
   
   
3 6

#include<stdio.h>
int main()
{
int n,i;
double a[51];
a[1]=3,a[2]=a[3]=6;
for(i=4;i<=50;i++)
a[i]=a[i-2]*2+a[i-1];
while(scanf("%d",&n)!=EOF)
printf("%.0lf\n",a[n]);
return 0;
}


找规律,不解释,推出来公式就好写了
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值