HDU1250 Hat's Fibonacci 【大数】
来源:互联网 发布:虚无世界用哪个java 编辑:程序博客网 时间:2024/06/05 12:43
Hat's Fibonacci
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7616 Accepted Submission(s): 2474
Problem Description
A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1.
F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4)
Your task is to take a number as input, and print that Fibonacci number.
F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4)
Your task is to take a number as input, and print that Fibonacci number.
Input
Each line will contain an integers. Process to end of file.
Output
For each case, output the result in a line.
Sample Input
100
Sample Output
4203968145672990846840663646Note:No generated Fibonacci number in excess of 2005 digits will be in the test data, ie. F(20) = 66526 has 5 digits.
import java.util.Scanner;import java.math.BigInteger;public class Main{public static void main(String[] args){Scanner cin = new Scanner(System.in);BigInteger a, b, c, d;BigInteger[] arr = new BigInteger[10000];arr[1] = arr[2] = arr[3] = arr[4] = BigInteger.ONE;arr[5] = BigInteger.valueOf(4);for(int i = 6; i < 10000; ++i)arr[i] = arr[i-1].add(arr[i-2]).add(arr[i-3]).add(arr[i-4]);int n;while(cin.hasNext()){n = cin.nextInt();System.out.println(arr[n]);}}}
0 0
- HDU1250 Hat's Fibonacci 【大数】
- HDU1250 Hat's Fibonacci(大数)
- HDU1250 Hat's Fibonacci 大数运算
- HDU1250~Hat's Fibonacci(大数加法)
- Hat's Fibonacci hdu1250
- hdu1250-Hat's Fibonacci
- hdu1250-Hat's Fibonacci
- HDU1250:Hat's Fibonacci
- hdu1250 Hat's Fibonacci
- HDU1250 Hat's Fibonacci
- hdu1250 Hat's Fibonacci
- HDU1250 Hat's Fibonacci 【亿进制】
- hdu1250 Hat's Fibonacci 高精度
- hdu1250 Hat's Fibonacci(高精度加)
- HDU1250--Hat's Fibonacci hdu(98)
- hdu1250(大 数)Hat's Fibonacci
- 【hdoj_1250】Hat's Fibonacci(大数)
- Hat's Fibonacci(大数)
- Unique Binary Search Trees I & II
- 线性规划与网络流24题の5 圆桌问题(二分图多重匹配)
- dancing links讲解
- 看来角度来看都说了看了看都是垃圾刚开始看了几个六级考试
- 互联网大会第三日看点:丁磊对话张朝阳
- HDU1250 Hat's Fibonacci 【大数】
- 内核hlist使用之pidhash散列表使用分析
- POJ--1159:Palindrome (DP求最长公共子序列)
- 组成原理复习
- 谷歌今年或发布两款大屏智能手机
- Lucene/Solr学习笔记(一)
- GitHub使用教程
- 黑马程序员—(iOS开发)OC开发技巧及核心语法---(九)
- QTableWidget翻译