The big flag-raising
来源:互联网 发布:ubuntu 16 输入法 编辑:程序博客网 时间:2024/06/05 02:41
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
12
Sample Output
36找规律,不解释,推出来公式就好写了#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;
}
0 0
- The big flag-raising
- The national flag
- Raising The Bar For Windows Rootkit Detection
- Raising The Bar For Windows Rootkit Detection
- ZOJ 3879 Capture the Flag
- cocoaPods Use the `$(inherited)` flag
- Linux: the big picture
- The big bang theory!
- The Big Real Mode
- The Big Bang Theory
- the big bang
- Linux: the big picture
- The Big Three Rule
- toj3474 The Big Dance
- The big bang S7E1
- The BIG Talk
- HNU13383:The Big Painting
- The big short
- 显示计算机特殊文件夹
- 【算法讲解】前缀函数(KMP的next函数)
- SDUTOJ 1291 数据结构之二叉树的建立与遍历(带返回值,指针引用,数组模拟3种方式)
- 湖南省2010ACM省赛集(更新中)
- Paper folding
- The big flag-raising
- Android 4.4 SD卡文件读写变化
- 关于AOE网求关键路径
- 堆排序算法
- Android 应用程序窗体显示状态操作(requestWindowFeature()的应用)
- Struts2数据传输的背后机制:ValueStack(值栈)
- setContentView()实现布局页面的跳转
- getResources()从应用中获取资源
- uva 1394 - And Then There Was One(约瑟夫环)