HDOJ 1297 Children’s Queue
来源:互联网 发布:淘宝在线装修工具 编辑:程序博客网 时间:2024/06/16 13:09
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?
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
123
Sample Output
124
Author
SmallBeer (CML)
Source
杭电ACM集训队训练赛(VIII)
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]);}}}
1 0
- HDOJ 1297:Children’s Queue
- HDOJ 1297 Children’s Queue
- ACM HDOJ 1297 (Children’s Queue)
- 1297 Children’s Queue
- 1297 Children’s Queue
- Children’s Queue 1297
- HDOJ 题目1297Children’s Queue(递推,大数)
- hdoj 1297 Children’s Queue 【高精度】【递推】
- hdoj.1297 Children’s Queue【大数+排列组合】 2015/08/06
- HDOJ/HDU 1297 Children’s Queue(推导~大数)
- ACM--学生排队--HDOJ 1297--Children’s Queue--大数
- hdu 1297 Children’s Queue
- 【HDU 1297】Children’s Queue
- HDU 1297 - Children’s Queue
- HDU 1297 Children’s Queue
- HDU 1297 Children’s Queue
- hdu 1297 Children’s Queue
- HDU 1297 Children’s Queue
- java中equals,hashcode和==的区别
- modem通讯连接过程
- php 验证身份证号码
- 哈弗曼编码和译码.cpp
- ORACLE DUL/PRM常见问题汇总FAQ
- HDOJ 1297 Children’s Queue
- 排序(6)---------归并排序(C语言实现)
- [杭电]Fibonacci Again
- MVVM架构~knockoutjs系列之验证成功提示显示
- 今天测试了一下深圳双界河科技有限公司的鹰眼豹速车牌识别系统, 还不错!
- 最短路 迪杰斯特拉.cpp
- 我要把我写过关于快速幂运算的题目都收集起来
- 经典算法之河内之塔
- WEB安全:文件上传漏洞