Children’s Queue(hdu1297+递推)
Children’s Queue
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 12101 Accepted Submission(s):
3953
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?
the EOF. In each case, there is only one integer n means the number of children
(1<=n<=1000)
number of queue satisfied the headmaster’s needs.
#include<stdio.h>
#include<string.h>
int f[][];
void init()
{
memset(f,,sizeof(f));
f[][]=;
f[][]=;
f[][]=;
f[][]=; for(int i=;i<=;i++)
{
int add=;
for(int j=;j<=;j++)
{
f[i][j]=f[i-][j]+f[i-][j]+f[i-][j]+add;
add=f[i][j]/;
f[i][j]%=;
if(add==&&f[i][j]==)break;
}
}
}
int main()
{
int n;
init();
while(scanf("%d",&n)!=EOF)
{
int k=;
while(!f[n][k])k--;
printf("%d",f[n][k--]);
for(;k>;k--)
{
printf("%04d",f[n][k]);
}
printf("\n");
}
return ;
}
Children’s Queue(hdu1297+递推)的更多相关文章
- HDU1297 Children’s Queue (高精度+递推)
Children’s Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 1297 Children’s Queue (递推、大数相加)
Children’s Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- (递推 大整数) Children’s Queue hdu1297
Children’s Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 【高精度递推】【HDU1297】Children’s Queue
Children's Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Children’s Queue HDU 1297 递推+大数
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1297 题目大意: 有n个同学, 站成一排, 要求 女生最少是两个站在一起, 问有多少种排列方式. 题 ...
- codeforces D. Queue 找规律+递推
题目链接: http://codeforces.com/problemset/problem/353/D?mobile=true H. Queue time limit per test 1 seco ...
- 矩阵快速幂(queue递推)
http://acm.hdu.edu.cn/showproblem.php?pid=2604 Queuing Time Limit: 10000/5000 MS (Java/Others) Me ...
- HDOJ/HDU 1297 Children’s Queue(推导~大数)
Problem Description There are many students in PHT School. One day, the headmaster whose name is Pig ...
- Flags-Ural1225简单递推
Time limit: 1.0 second Memory limit: 64 MB On the Day of the Flag of Russia a shop-owner decided to ...
随机推荐
- ThinkPHP 5隐藏public/index.php方法
1.复制public下的index.php与.htaccess文件至根目录: 2.直接修改index.php,将内容修改为:<?php require 'public/index.php'; ? ...
- jsbridge的js封装
/*注意:源生app需要配置jsbridge的环境,而在前端页面中需要下方封装代码,既可以达到调用app方法的功能和注册供app调用的方法1.注册方法:注册后,供app调用,注册时,同名函数,下一个会 ...
- 2.Git基础-仓库的获取方式与Git文件的状态变化周期(生命周期)
1.仓库的获取 Git仓库的获取有两种方式: 1.从现有目录或者是项目中导入所有文件到Git中. 2.从一个服务器clone一个现有的Git仓库. 如果使用第一种方式,只需要在你希望被Git进行管理的 ...
- yum安装Elasticsearch5.x
这里演示YUM和RPM两种方式安装Elasticsearch 下载并安装 public signing key: rpm --import https://artifacts.elastic.co/G ...
- .NetCore外国一些高质量博客分享
前言 我之前看.netcore一些问题时候,用bing搜索工具搜到了一些外国人的博客.翻看以下,有学习的价值,就分享在这里了. 个人博客 andrewlock.net 最新几篇如下,一看标题就知道很有 ...
- Apache Pulsar简介
Apache Pulsar What is Pulsar "Pulsar is a distributed pub-sub messaging platform with a very fl ...
- SpringBoot配置Cors解决跨域请求问题
一.同源策略简介 同源策略[same origin policy]是浏览器的一个安全功能,不同源的客户端脚本在没有明确授权的情况下,不能读写对方资源. 同源策略是浏览器安全的基石. 什么是源 源[or ...
- MySQL索引的概念
索引是一种特殊的文件(InnoDB数据表上的索引是表空间的一个组成部分),它们包含着对数据表里所有记录的引用指针.更通俗的说,数据库索引好比是一本书前面的目录,能加快数据库的查询速度. 索引分为聚簇索 ...
- Java 并发编程-再谈 AbstractQueuedSynchronizer 2:共享模式与基于 Condition 的等待 / 通知机制实现
共享模式acquire实现流程 上文我们讲解了AbstractQueuedSynchronizer独占模式的acquire实现流程,本文趁热打铁继续看一下AbstractQueuedSynchroni ...
- 基于jQuery消息提示框插件Tipso
今天要分享的这款jQuery消息提示框插件名叫Tipso,它的特点是可以定义提示框的显示位置,以及动态改变提示框的提示内容,应该说是一款相当灵活的jQuery消息提示框插件.效果图如下: 在线预览 ...