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

JAVA大数....

Children’s Queue

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

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
 

Author
SmallBeer (CML)
 

Source
 
import java.util.*;
import java.math.*; public class Main
{
public static void main(String[] args)
{
Scanner cin=new Scanner(System.in); BigInteger[] a=new BigInteger[1100];
a[1]=BigInteger.valueOf(1);
a[2]=BigInteger.valueOf(2);
a[3]=BigInteger.valueOf(4);
a[4]=BigInteger.valueOf(7);
for(int i=5;i<=1000;i++)
{
a[i]=a[i-4].add(a[i-2].add(a[i-1]));
} while(cin.hasNextInt())
{
int n=cin.nextInt();
System.out.println(a[n]);
}
}
}

HDOJ 1297 Children’s Queue的更多相关文章

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

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

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

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

  3. 【HDOJ】1297 Children’s Queue

    递推,最近发现自己做递推的题总是没有思路.下周多练习.对于f(n)可以在第n个位置为男生,此时共有f(n-1)种情况:若在第n个位置为女生,因此第n-1个位置也必须为女生.此时有两种情况,一种情况是在 ...

  4. 杭电ACM 1297 Children’s Queue

    这道题是排序问题,可以用递归方法解决. 计算F(n): 一:当最后一个是男孩M时候,前面n-1个随便排出来,只要符合规则就可以,即是F(n-1): 二:当最后一个是女孩F时候,第n-1个肯定是女孩F, ...

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

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

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

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

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

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

  8. Children’s Queue

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

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

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

随机推荐

  1. Cracking The Coding Interview 5.5

    #include <iostream> #include <vector> using namespace std; int getNum1(int N) { int num= ...

  2. 用matlab绘制中国地图

    reference:https://jingyan.baidu.com/article/870c6fc36fdacfb03ee4be58.html shp: http://muchong.com/ht ...

  3. IDEA中maven的依赖jar包报红

    问题描述: 查看本地的repository中有相关的jar包,但是在IDEA中就是报红(下面红色波浪线) 解决方法: 将pom.xml中相关的dependcy配置注释掉,maven中jar包就会删除. ...

  4. DOS debug 命令的详细用法

    DOS下的DEBUG命令的详细用法       2 推荐 名称 解释 格式 a (Assemble) 逐行汇编 a [address] c (Compare) 比较两内存块 c range addre ...

  5. 人生苦短,我用python,为什么选择python,python简介

    认识 Python 人生苦短,我用 Python —— Life is short, you need Python  目标 Python 的起源 为什么要用 Python? Python 的特点 ...

  6. tensorflow-优化器

    优化器可以通俗的理解成梯度下降那一套流程. 梯度下降 基本流程 a. 损失函数 b. 求导,计算梯度 c. 更新参数 d. 迭代下一批样本 可以对照着理解tf. tf 优化器 正常使用流程 a. 创建 ...

  7. [rancher-net]

    ip rule命令 rancher网络全解读 arp命令查询 rancher managed network 实践 docker自定义网桥 iptables增删改查 shell脚本调试技术

  8. python调用shell脚本

    # coding=utf-8   //设置文本格式import os            //导入os方法print('hello')n=os.system('/home/csliyb/kjqy_x ...

  9. <Parquet><Physical Properties><Best practice><With impala>

    Parquet Parquet is a columnar storage format for Hadoop. Parquet is designed to make the advantages ...

  10. python3 自学第一天,python 介绍

    1.python的介绍: 是一个无聊的人创造的 2.python的格式: 跟java这些语言格式不一样用的是缩进来编码(区块) 一般是四个空格,这样更简洁 3.编码格式: python3跟python ...