HDUOJ Children’s Queue

时间:2022-12-17 12:24:33

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 &lpar;高精度&plus;递推&rpar;

    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&plus;递推)

    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&sol;HDU 1297 Children’s Queue&lpar;推导~大数&rpar;

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

  9. Children’s Queue HDU 1297 递推&plus;大数

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

随机推荐

  1. jsapi支付,提示redirect&lowbar;uri 参数错误

    检查授权目录(微信支付——配置中心) appid MCHID KEYS 配置参数是否正确 appsecrect 配置是否正确(开发者中心) 如果是使用测试链接,需要同时指定测试授权目录,测试账号,并且 ...

  2. OpenSuse13&period;2安装CUDA Toolkit 7&period;5

    此次安装过程有点曲折,不过最后还是能成功安装,由于没细细看官方的安装文档,导致花了很多时间安装,希望此文能让想装CUDA的同学少走点弯路 1.NVIDIA Driver是否要装 刚开始要装CUDA时, ...

  3. mysql忘记密码,修改密码重新安装的一些问题

    前言 想要装cobra,却意外发现mysql连接失败,命令行连一下发现无论怎么样都连不上了. 我能想到的密码都用上了,糟糕!看来只能修改密码,或者重装了. 最后是重装搞定的,当然也发现了正确的修改密码 ...

  4. Python编程核心内容之一——Function(函数)

    Python版本:3.6.2  操作系统:Windows  作者:SmallWZQ 截至上篇随笔<Python数据结构之四--set(集合)>,Python基础知识也介绍好了.接下来准备干 ...

  5. 真正理解拉格朗日乘子法和 KKT 条件

        这篇博文中直观上讲解了拉格朗日乘子法和 KKT 条件,对偶问题等内容.     首先从无约束的优化问题讲起,一般就是要使一个表达式取到最小值: \[min \quad f(x)\]     如 ...

  6. 第二卷 Spring羊群理论

    写在前面: 话说这天小迦罗在和哑圣观察者聊天时,哑圣谈到自己比较喜欢吃羊,这时候小迦罗说自己的爸爸也喜欢吃,就给哑圣老师讲了他小时候在春天里放羊的故事还有参观Spring的事情.(后面以此抛砖引玉可以 ...

  7. 信步漫谈之Jenkins&mdash&semi;集成环境搭建

    一.环境准备 1)Jenkins 部署 WAR 包:jenkins.war(2.164.2 版本,WAR 包官方下载路径:https://jenkins.io/download/)2)Tomcat 服 ...

  8. git 删除与撤回

    Git 删除与撤回 标签: git 版本管理 删除文件 撤回删除操作 2017年01月13日 22:56:27786人阅读 评论(0) 收藏 举报  分类: Git(4)  版权声明:本文为博主原创文 ...

  9. 一个好看的php验证码源码

    <?php     $w = 80; //设置图片宽和高 $h = 26; $str = Array(); //用来存储随机码 $string = "ABCDEFGHIJKLMNOPQ ...

  10. Cortex-M3的一些概念

    [工作模式] 线程模式(Thread mode):处理器复位或异常退出时为此模式.此模式下的代码可以是特权代码也可以是用户代码,通过CONTROL[0]控制.处理模式(Handler mode):出现 ...