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. 构建一个.net的干货类库,以便于快速的开发 - 前言

    前言: 工作已经快两年了,项目也做过不少,不知道大家有没有一个习惯,就是把在做项目过程中那些好的方法记录下来.我觉得这个习惯在开发的过程中还是很有用的,举个例子,我之前做过一个支付宝的支付功能,然后把 ...

  2. WebForm vs MVC

    What is ASP.NET? ASP.NET is a Microsoft’s Web application framework built on Common language runtime ...

  3. Apache ab使用指南

    Apache ab使用图例: 其中比较重要的两个指标要特别注意: Requests per second:表示平均每秒事务数,相当于LR的TPS Time per second:用户请求平均响应时间和 ...

  4. Pycharm消除波浪线

    PyCharm使用了较为严格的PEP8检查规则,稍微有点错误就会出现波浪线提示.那么怎么消除这些波浪线呢?一个简单粗暴的方法就是:在编辑器的右下角有个小人形状的按钮,点开之后有个滚动条,将滚动条滑动到 ...

  5. golang 自定义time.Time json输出格式

    工作中使用golang时,遇到了一个问题.声明的struct含time.Time类型.使用json格式化struct时,time.Time被格式化成”2006-01-02T15:04:05.99999 ...

  6. Vue指令3:v-for

    列表渲染 我们用 v-for 指令根据一组数组的选项列表进行渲染.v-for 指令需要使用item in items 形式的特殊语法,items 是源数据数组并且 item 是数组元素迭代的别名. & ...

  7. top命令的用法

    top命令的用法 2018年07月15日 09:50:04 zhuoya_ 阅读数:1858    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/z ...

  8. Django - 模版之继承

    模版继承: 当多个html有共同之处时,需要建立一个模版html(master.html) 1.在模版html中,写入公共的部分: 备注:在模版中,我们可以指定多个block ,其中,可以在标题,cs ...

  9. JAVA基础——Date和Calendar类

    1计算某一月份的最大天数 Calendar time=Calendar.getInstance(); time.clear(); time.set(Calendar.YEAR,year); //yea ...

  10. 「 RQNOJ PID204 」 特种部队

    解题思路 看了一下题解,感觉题解貌似有些错误.所以把我的见解放在这里,希望路过的大佬可以帮忙解释一下 QAQ 就是这里的更新 $dp[i-1][i]$ 和 $dp[i][i-1]$ 的时候,之前博主说 ...