Fibbonacci Number

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 22530    Accepted Submission(s): 10375

Problem Description
Your objective for this question is to develop a program which will generate a fibbonacci number. The fibbonacci function is defined as such:

f(0) = 0
f(1) = 1
f(n) = f(n-1) + f(n-2)

Your program should be able to handle values of n in the range 0 to 50.
 

Input
Each test case consists of one integer n in a single line where 0≤n≤50. The input is terminated by -1.
 

Output
Print out the answer in a single line for each test case.
 

Sample Input
3
4
5
-1
 

Sample Output
2
3
5
Hint
Note:

you can use 64bit integer: __int64

费波纳列数

#include <iostream>
using namespace std; const int limit = 51;
_int64 fib[limit]; int main()
{
int num;
fib[0] = 0;
fib[1] = 1;
for (int i = 2; i <= limit; i++)
{
fib[i] = fib[i - 1] + fib[i - 2];
} while (cin >> num && num!=-1)
{
cout << fib[num] << endl;
}
return 0;
}

hdoj:2070的更多相关文章

  1. 算法——A*——HDOJ:1813

    Escape from Tetris Time Limit: 12000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  2. hdoj:题目分类

    基础题: 1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.1032.1037.1040.1048.1056.1058. ...

  3. HDOJ:1533-Going Home(最小费用流)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1533 解题心得: 第一次写最小费用流的题,去hdoj上找了一个入门级题目,建图比较简单,用了spfa和 ...

  4. hdoj:2086

    A1 = ? Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...

  5. hdoj:2085

    核反应堆 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  6. hdoj:2084

    数塔 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submissi ...

  7. HDOJ:6333-Problem B. Harvest of Apples(组合数学+莫队算法+逆元)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6333 解题心得: 这个题可以说是十分精彩了,首先推组合数学的公式,其中一个很重要的公式是Cnm = C ...

  8. HDOJ:6356-Glad You Came(线段树剪枝)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6356 解题心得: 现在深深的知道了算法复杂度的重要了,这个题算复杂度的时候还要把一些常数也算出来,不然 ...

  9. hdoj:2075

    A|B? Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

随机推荐

  1. Emgucv - 下载、安装、配置

    工欲善其事,必先利其器. 一.下载 Emgucv学习之前,我们先要搭建好开发环-Emgucv库.VS开发平台. (1)VS开发平台,个人觉得VS2015挺好用的,比如:自定义窗口布局.更优的代码编辑器 ...

  2. Mac使用Clion配置OpenGL

    Mac使用Clion配置OpenGL 之前博主是用Xcode配置的openGL,但后来因为要与非Mac队友合作,于是大家决定统一使用Clion,博主于是再次配置开发环境,这里记录一下 预先准备 Mac ...

  3. centos7.4 python3.6 Anaconda3 的下安装tensorflow

    参考这个博客 https://blog.csdn.net/learn_tech/article/details/79861683 在anaconda环境下,安装tensorflow 2018年04月0 ...

  4. angular学习笔记(3)- MVC

    angular1学习笔记(3)- MVC --- MVC终极目标 - 模块化和复用 AngularJs的MVC是借助于$scope实现的!!! 神奇的$scope: 1.$scope是一个POJO(P ...

  5. 转 What is Redis and what do I use it for?

    原文: http://stackoverflow.com/questions/7888880/what-is-redis-and-what-do-i-use-it-for Redis = Remote ...

  6. macOS Sierra WiFi connecting problem

    吐槽一下,苹果的质量管控越来越差了. macOS Sierra有时突然或升级后会遇到wifi不停重连连不上问题,现象为不停地连接wifi. 网上有人说删除 /Library/Preferences/S ...

  7. poj3009 Curling 2.0(很好的题 DFS)

    https://vjudge.net/problem/POJ-3009 做完这道题,感觉自己对dfs的理解应该又深刻了. 1.一般来说最小步数都用bfs求,但是这题因为状态记录很麻烦,所以可以用dfs ...

  8. Mac添加自定义启动图标到Launchpad

    1.使用Automator进行录制 2.选择Application 3.使用运行shell脚本 4.保存在应用程序 5.效果 参考: https://apple.stackexchange.com/q ...

  9. Mac安装Linux的KVM管理工具virt-manager

    安装: brew tap jeffreywildman/homebrew-virt-manager brew install virt-manager virt-viewer 中途会碰到很多问题,可以 ...

  10. Sqoop导入到hdfs

    1.注意win下直接复制进linux 改一下--等 sqoop-list-databases --connect jdbc:mysql://122.206.79.212:3306/ --usernam ...