Fibbonacci Number

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 13234    Accepted Submission(s): 6628

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

#include<iostream>
#include<cstring>
using namespace std; int main()
{
__int64 a[55];
a[0]=0,a[1]=1;
for(int i=2;i<=50;i++)
a[i]=a[i-1]+a[i-2]; int n;
while(cin>>n)
{
if(n==-1) break;
printf("%I64d\n",a[n]);
}
return 0;
}

HDUJ 2070 Fibbonacci Number的更多相关文章

  1. HDU 2070 Fibbonacci Number

    Fibbonacci Number Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  2. 杭电2070 Fibbonacci Number

    Fibbonacci Number Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  3. Fibbonacci Number(杭电2070)

    /*Fibbonacci Number Problem Description Your objective for this question is to develop a program whi ...

  4. JSU省赛队员选拔赛个人赛1(Coin Change、Fibbonacci Number、Max Num、单词数、无限的路、叠筐)

    JSU省赛队员选拔赛个人赛1 一.题目概述: A.Coin Change(暴力求解.动态规划)     B.Fibbonacci Number(递推求解) C.Max Num(排序.比较) D.单词数 ...

  5. 2Q - Fibbonacci Number

    Your objective for this question is to develop a program which will generate a fibbonacci number. Th ...

  6. 杭电oj2031、2033、2070、2071、2075、2089、2090、2092、2096-2099

    2031  进制转换 #include<stdio.h> #include<string.h> int main(){ int n,i,r,x,j,flag; ]; while ...

  7. hdoj:2070

    Fibbonacci Number Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  8. HDU100题简要题解(2070~2079)

    HDU2070 Fibbonacci Number 题目链接 Problem Description Your objective for this question is to develop a ...

  9. [Python] Advanced features

    Slicing 12345 L[:10:2] # [0, 2, 4, 6, 8]L[::5] # 所有数,每5个取一个# [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, ...

随机推荐

  1. sublime text 3 使用技巧

    一.下载 官网下载合适的版本(http://www.sublimetext.com/3) 二.破解 执行 Help->Enter license 粘贴你的License代码 ----- BEGI ...

  2. 在dataGridView空间中添加数据

    //查询信息sql语句 string sql = "select studentName,addres from student"; SqlDataAdapter adapter ...

  3. java用匿名内部类实现多线程堆内存变量共享

    匿名内部类介绍:http://www.cnblogs.com/nerxious/archive/2013/01/25/2876489.html 用Runnable模拟实现共享堆内存变量 import ...

  4. IFormattable,ICustomFormatter, IFormatProvider接口

    定                 义 1.IFormattable   提供一种功能,用以将对象的值格式化为字符串表示形式. 2.IFormatProvider  提供用于检索控制格式化的对象的机制 ...

  5. gdb如何保存和读取断点

    刚开始在linux下学编程使用gdb的同学可能会发现,每次用gdb设置断点调试程序,但下次打开的时候所有断点都没有了,很不方便.下面介绍保存和读取断点的方法. 1. 保存断点 先用info b 查看一 ...

  6. binlog_format不同模式下,对mysqlbinlog恢复的影响

      binlog_format='mixed' (root)[(none)]>use test; Reading table information for completion of tabl ...

  7. 怎么忽略ESLint校验

    方法一: 打开eslint的配置文件.eslintrc.js rules: { // allow async-await 'generator-star-spacing': 'off', // all ...

  8. java.lang.NoSuchFieldError: DEFAULT_INCOMPATIBLE_IMPROVEMENTS

    解决方案: 启动类上加@EnableAutoConfiguration(exclude = { FreeMarkerAutoConfiguration.class }) 或者在配置文件添加spring ...

  9. PIE SDK 监督分类对话框类(SupervisedClassificaitonDialog)使用经验

    最近研究遥感,用到分类算法,PIE SDK正好提供了一些方法可供调用,他们的官方博客上也有相应的示例代码(可参考:https://www.cnblogs.com/PIESat/p/10725270.h ...

  10. linux vim 常用操作

    vim 字符级 上k下j左h右i,键盘的方向键也可以移动 单词级 b上个单词首字母 w下个单词首字母 e下个单词的尾字母 行级 0行首 $行尾 删除 dd 删除光标所在行 文档级 gg 文档首行,首个 ...