HDUJ 1715 大菲波数
来源:互联网 发布:unity3d素材 编辑:程序博客网 时间:2024/05/20 01:12
大菲波数
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11074 Accepted Submission(s): 3743
Problem Description
Fibonacci数列,定义如下:
f(1)=f(2)=1
f(n)=f(n-1)+f(n-2) n>=3。
计算第n项Fibonacci数值。
f(1)=f(2)=1
f(n)=f(n-1)+f(n-2) n>=3。
计算第n项Fibonacci数值。
Input
输入第一行为一个整数N,接下来N行为整数Pi(1<=Pi<=1000)。
Output
输出为N行,每行为对应的f(Pi)。
Sample Input
512345
Sample Output
11235
import java.util.Scanner;import java.math.BigInteger;public class yhrtr {public static void main(String[] args) {Scanner cin = new Scanner (System.in);BigInteger s[] = new BigInteger[1005];s[1] = BigInteger.ONE;s[2] = BigInteger.ONE;for(int i=3;i<=1000;i++)s[i] = s[i-1].add(s[i-2]);int n = cin.nextInt();for(int i=0;i<n;i++){int m = cin.nextInt();System.out.println(s[m]);}}}
0 0
- HDUJ 1715 大菲波数
- hduj 1114 完全背包
- HDUJ 1425 sort
- HDUJ 2015 偶数求和
- HDUJ 2017 字符串统计
- HDUJ 2019 数列有序!
- HDUJ 2020 绝对值排序
- HDUJ 2030 字符统计
- HDUJ 2090 算菜家
- HDUJ 2070 Fibbonacci Number
- HDUJ 2071 Max Num
- HDUJ 2022 海选女主角
- HDUJ 2040 亲和数
- HDUJ 2043 密码
- HDUJ 2039 三角形
- HDUJ 1020 Encoding
- HDUJ 2052 Picture 模拟
- HDUJ 2053 Switch Game
- Oracle Redo Log Buffer的大小设置
- java类的访问权限解析
- UVa 10608 - Friends
- iOS7 Networking with NSURLSession: Part 1
- ListView的Item不能点击的解决方法
- HDUJ 1715 大菲波数
- #第六天 笔记 7/28
- OCP 1Z0 053 224
- tomcat加入log功能
- C++技术问题总结-第1篇 内存布局
- Windows驱动开发(二)
- 关于Linux服务器集群的开机自启动和有序关闭应用的实现
- poj-2352
- 线程同步与异步