Children’s Queue

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8835    Accepted Submission(s): 2813

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
大数。。 公式 f(x)=f(x-1)+f(x-2)-F(x-4);
代码:
 #include<iostream>
#include<cstdio>
#define maxn 250
#define len 1000
using namespace std;
int a[len+][maxn+]={{},{},{},{}};
int main()
{
int i,j,n,s,c=;
for(i=;i<=len;i++)
{
for(c=j=;j<=maxn;j++)
{
s=a[i-][j]+a[i-][j]+a[i-][j]+c;
a[i][j]=s%;
c=(s-a[i][j])/;
}
}
while(cin>>n)
{
for(i=maxn;a[n-][i]==;i--);
for(j=i;j>=;j--)
{
printf("%d",a[n-][j]);
}
printf("\n");
}
return ;
}

HDUOJ 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

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

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

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

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

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

  6. HDOJ 1297 Children’s Queue

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

  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. 网站功能操作分布引导插件:Intro.js介绍;React里如何使用Intro.js以及如何进行分页导航

    插件作用:使用向导,引导新用户正确使用Web网站.我的环境是React+Mobx. 基本使用介绍,参加代码地址里的README.md:https://github.com/usablica/intro ...

  2. Redis设计与实现读书笔记——简单动态字符串

    前言 项目里用到了redis数据结构,不想只是简单的调用api,这里对我的读书笔记做一下记录.原文地址: http://www.redisbook.com/en/latest/internal-dat ...

  3. Android组件之自定义ContentProvider

    Android的数据存储有五种方式Shared Preferences.网络存储.文件存储.外储存储.SQLite,一般这些存储都只是在单独的一个应用程序之中达到一个数据的共享,有时候我们需要操作其他 ...

  4. 动态装载外部JavaScript脚本文件

    当我们请求一个URL地址时,浏览器会从远程服务器装载各种所需的资源,如JavaScript.CSS.图片等.而在加载JavaScript时,常常会发生下面这种情况: 也就是说,当浏览器碰到Script ...

  5. jQuery练手:仿新浪微博图片文字列表淡进淡出上下滚动效果

    1.效果及功能说明 仿新浪微博图片文字列表上下淡进淡出间歇上下滚动 2.实现原理 首先要设定div内只能显示4个图片那么多出来的图片会自动隐藏然后在给图片添加一个动画的事件让他们可以滚动的播放出来上下 ...

  6. 图片文字OCR识别-tesseract-ocr

    帮助文件:https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc 下载地址:https://github. ...

  7. [转] SSH免密码登陆以及穿越跳板机

    原文链接:http://www.cnblogs.com/lucantang/p/3315329.html SSH免密码登陆以及穿越跳板机   1. 免密码直连  [user@hostA ~] $ssh ...

  8. [Node.js]32. Level 7: Working with Lists -- Redis

    As we saw in the video, redis can do more than just simple key-value pairs. We are going to be using ...

  9. 【OpenCV新手教程之十七】OpenCV重映射 &amp; SURF特征点检測合辑

    本系列文章由@浅墨_毛星云 出品.转载请注明出处. 文章链接:http://blog.csdn.net/poem_qianmo/article/details/30974513 作者:毛星云(浅墨)  ...

  10. WebService SOAP、Restful和HTTP(post/get)请求区别

    web service(SOAP) Webservice的一个最基本的目的就是提供在各个不同平台的不同应用系统的协同工作能力. Web service 就是一个应用程序,它向外界暴露出一个能够通过We ...