Children’s Queue

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 10040    Accepted Submission(s): 3198

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?
 
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
1
2
3
 
Sample Output
1
2
4
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int n;
int f[1001][101] = {0};
f[0][1]=1;
f[1][1]=1;
f[2][1]=2;
f[3][1]=4;
for(int i=4; i<1001; ++i)
{
for(int j=1;j<101;++j)
{
f[i][j]+=f[i-1][j]+f[i-2][j]+f[i-4][j];
f[i][j+1]+=f[i][j]/10000;
f[i][j]%=10000;
}
} while(cin>>n)
{int j=100;
while(!f[n][j])
{j--;}
cout<<f[n][j];
j--;
for(;j>0;j--)
printf("%04d", f[n][j]);
cout<<endl; } return 0;
}

Children’s Queue的更多相关文章

  1. HDU1297 Children’s Queue (高精度+递推)

    Children’s Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  2. 【高精度递推】【HDU1297】Children’s Queue

    Children's Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  3. Children’s Queue(hdu1297+递推)

    Children’s Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...

  4. (递推 大整数) Children’s Queue hdu1297

    Children’s Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  5. HDOJ 1297 Children’s Queue

    版权声明:来自: 码代码的猿猿的AC之路 http://blog.csdn.net/ck_boss https://blog.csdn.net/u012797220/article/details/3 ...

  6. HDUOJ Children’s Queue

    Children’s Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  7. HDU 1297 Children’s Queue (递推、大数相加)

    Children’s Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. HDOJ/HDU 1297 Children’s Queue(推导~大数)

    Problem Description There are many students in PHT School. One day, the headmaster whose name is Pig ...

  9. Children’s Queue HDU 1297 递推+大数

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1297 题目大意: 有n个同学, 站成一排, 要求 女生最少是两个站在一起, 问有多少种排列方式. 题 ...

随机推荐

  1. phpc.sinaapp.com 加密的解密方法

    原文:phpc.sinaapp.com 加密的解密方法 很简单,用类似phpjm的解密方式,替换掉_inc.php中最后一个return中的eval为print就出来了.

  2. 函数式编程很难,这正是你要学习它的原因 | 外刊IT评论网

    函数式编程很难,这正是你要学习它的原因 | 外刊IT评论网 函数式编程很难,这正是你要学习它的原因 156 次分享 新浪微博 腾讯微博 Tweet 人人网 QQ空间 很奇怪不是,很少有人每天都使用函数 ...

  3. deque,list,queue,priority_queue

    1.deque deque双端队列容器与vector一样,采用线性表顺序存储结构,但与vector唯一不同的是,deque采用分块的线性存储结构来存 储数据,每块的大小一般为512字节,称为一个deq ...

  4. hdu3329(2次dfs)

    传送门:The Flood 题意:当水的高度升为多少的时候,能够将这块区域分为两个部分. 分析:枚举高度,先从外围开始一次dfs,将水能淹没的标记,然后看非标记的是否已分为多块. #include&l ...

  5. 《Qt编程的艺术》——9.1 QtSql模块的结构

    QtSql是一个独立的库,如果需要的话,它可以加载附加的插件.不同于QtCore和QtGui,它的内容默认情况下并没有整合进生成的project中.要使用这个库,我们要编辑 .pro文件,添加下列条目 ...

  6. poj3268(最短路)

    题目连接:http://poj.org/problem?id=3268 题意:给出n个点和m条单向边,现在所有牛要到牛x那里去参加聚会,并且所有牛参加聚会后还要回来,给你牛x,除了牛x之外的牛,他们都 ...

  7. Vsphere client 无法登陆VCenter 处理的方法

    上周做安全的时候将DC.DB和VCenter 三台机器的防火墙都启用了,结果Vcenter 登陆的时候总是提示服务器没有响应,连web client 都无法登陆. 处理过程 一.首先要保证 vmvar ...

  8. HYSBZ 2243(树链剖分)

    题目连接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=28982#problem/D 题意:给定一棵有n个节点的无根树及点权和m个操作, ...

  9. codefroce D. Powerful array[初识块状数组]

    codefroce D. Powerful array[初识块状数组] 由于是初始所以,仅仅能先用别人的分析.囧... 题目: 给定一个数列:A1, A2,--,An,定义Ks为区间(l,r)中s出现 ...

  10. php(LAMP)开发环境配置相关问题及解决办法

    相信很多像我一样初次接触到php开发的人,在配置基本的开发环境时都是一头雾水,为此小编特写下自己在安装配置php开发环境过程中遇到的一些问题,及解决办法. 1.LAMP组合,安装centons+apa ...