Children’s Queue
来源:互联网 发布:sqlserver union 编辑:程序博客网 时间:2024/06/06 19:10
http://acm.hdu.edu.cn/diy/contest_showproblem.php?pid=1001&cid=22706
Problem 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
Author
Source
杭电ACM集训队训练赛(VIII)
#include<iostream>using namespace std;int a[1001][300];int main(){ int i,j,n,k; a[1][0] = 1; a[2][0] = 2; a[3][0] = 4; a[4][0] = 7; for(i = 5; i < 1001; i++) { k = 0; for(j = 0; j < 300; j++) { a[i][j] = a[i-1][j] + a[i-2][j] + a[i-4][j] + k; k = a[i][j] / 10; a[i][j] %= 10; } } while(cin >> n) { i = 299; while(i >= 0 && !a[n][i]) i--; while(i >= 0) cout << a[n][i--]; cout << endl; } 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
- JS setTimeout() 传参
- C++ primer第二次阅读学习笔记(第11章:泛型算法)
- viewport meta 标签在手机浏览器上控制布局
- 如何百度蜘蛛喜欢你
- C++与VB异同之面向对象方法比较(一)
- Children’s Queue
- Androidannotations——开源框架简介&简易使用准备
- 贪心算法之哈夫曼编码
- 蟠桃记
- java基础15
- Androidannotations——Home主页,了解AndroidAnnotations
- svn标准目录结构解说
- 母牛的故事
- AndroidAnnotations——How It Works,AndroidAnnotation是如何工作的