Children’s Queue
来源:互联网 发布:java函数命名规范 编辑:程序博客网 时间:2024/06/01 10:23
Children’s Queue
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1271 Accepted Submission(s): 662Problem Description
There are many students in PHT School. One day, the headmaster whose name is PigHeader wanted all students stand in a line. He prescribed that girl can not be in single. In other words, either no girl in the queue or more than one girl stands side by side. The case n=4 (n is the number of children) is like
FFFF, FFFM, MFFF, FFMM, MFFM, MMFF, MMMM
Here F stands for a girl and M stands for a boy. The total number of queue satisfied the headmaster’s needs is 7. Can you make a program to find the total number of queue with n children?
FFFF, FFFM, MFFF, FFMM, MFFM, MMFF, MMMM
Here F stands for a girl and M stands for a boy. The total number of queue satisfied the headmaster’s needs is 7. Can you make a program to find the total number of queue with n children?
Input
There are multiple cases in this problem and ended by the EOF. In each case, there is only one integer n means the number of children (1<=n<=1000)
Output
For each test case, there is only one integer means the number of queue satisfied the headmaster’s needs.
Sample Input
123
Sample Output
124
#include<stdio.h>//又是大数加法类的#include<string.h>using namespace std;char p[1005][1001];void add(int x,int y){ int a,b; a=strlen(p[x]); b=strlen(p[y]); int z=0; int tx,ty,t,i=0; while(i<a||z==1){ tx=ty=t=0; if(i<a) tx=p[x][i]-'0'; if(i<b) ty=p[y][i]-'0'; t=tx+ty+z; if(t>=10){ t=t-10; z=1; } else z=0; p[x][i]=t+'0'; i++; }}int main(){ int n,i; p[1][0]='1'; p[2][0]='2'; p[3][0]='4'; p[4][0]='7'; for(i=5;i<=1000;i++){strcpy(p[i],p[i-1]); add(i,i-2); add(i,i-4); } while(scanf("%d",&n)!=EOF){ for(i=strlen(p[n])-1;i>=0;i--) printf("%c",p[n][i]); printf("\n"); } return 0;}
阅读全文
0 0
- 1297 Children’s Queue
- 1297 Children’s Queue
- Children’s Queue .
- ACM--Children’s Queue
- hdu1297 Children’s Queue
- Children’s Queue
- HDU1297:Children’s Queue
- HDU1297 Children’s Queue
- hdu Children’s Queue
- hdu children's queue
- Children’s Queue 1297
- Children’s Queue
- Children’s Queue
- Children’s Queue
- Children’s Queue
- 高精度-Children’s Queue
- HDU Children’s Queue
- HDU1297 Children’s Queue
- 解析数据出错:reason: '-[__NSCFArray bytes]: unrecognized selector sent to instance 0x18056b30'
- sequence序列概念及作用
- 计算机中的M(兆)和国际单位制中的M(兆)怎么去理解?
- Windows线程(一)
- ffmpeg -resize and scale
- Children’s Queue
- ipnut (表单)
- WPF控件之ScrollViewer
- css自动换行问题
- AES加密/解密算法 128bit、192bit、256bit秘钥 支持CBC 可直接在MCU上运行
- Server.MapPath()
- hive账单表算连续逾期以及累计逾期
- jquery 根据name属性查找元素
- vue+node+webpack