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. LeetCode: Implement strStr() [027]

    [题目] Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if ...

  2. VS2010+OpenCV2.4.3配置

    VS2010+OpenCV2.4.3配置:  环境变量path: D:\openCV2.4.3\opencv\build\x86\vc10\bin  项目-属性-VC++目录:(vs2008中,工具- ...

  3. hdu 4548 美素数 超级大水题

    美素数 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submis ...

  4. Merge Interval leetcode java

    题目: Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6] ...

  5. mybatis 针对SQL Server 的 主键id生成策略

    SQL Server中命令: select newId()  ,可以得到SQL server数据库原生的UUID值,因此我们可以将这条指令写到 Mybatis的主键生成策略配置selectKey中. ...

  6. android 创建通知栏Notification

    ///// 第一步:获取NotificationManager NotificationManager nm = (NotificationManager) getSystemService(Cont ...

  7. magento upsell from cur_category

    <?php /** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Academic Free Li ...

  8. 输入框提示文字跨浏览器的placeholder-jQuery版

    <script type="text/javascript" src="jquery-1.7.2.min.js"></script> & ...

  9. 【Node.js】初体验之安装和HelloWorld

    听说Node.js是个蛮吊的东东.中午休息时间有限,暂时看了下知道怎么安装和初步使用了. 1.安装: 到Node.js官网下载就可以了,才5M多点,双击后按步骤安装就可以了. 2."Hell ...

  10. Linux History安全问题【保存记录防止删除】+完善Linux/UNIX审计 将每个shell命令记入日志

    2011-09-27 22:11:51|  分类: rhel5_033|举报|字号 订阅       Linux利用PROMPT_COMMAND实现审计功能 这个系统审计,记录什么用户,在什么时间,做 ...