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 反射初体验

    一.获取对象中的所有属性 Type是.net定义的一个反射的类.通过反射获取到对象的所有属性,然后根据属性获取对象对应属性所对应的值. 使用PropertyInfo,请引用命名空间using Syst ...

  2. 关于FLASK WEB开发8d 数据库迁移的问题

    首先, 第一步,要删除data-dev.sqlite这个数据库 第二步,进行下面的重建 暂时的解决办法是: python manage.py shell In [2]: from app import ...

  3. Android 6.0权限分组

    Android系统从6.0开始将权限分为一般权限和危险权限,一般权限指不涉及用户隐私的一些权限,比如Internet权限.危险权限指涉及获取用户隐私的一些操作所需要的权限,比如读取用户地理位置的权限. ...

  4. 连接服务器的mysql

    在服务器配置好Mysql 数据库,在客户端连接,报错: 解决方法: 1.在MySQL 数据库中修改user表,将host 中的localhoust 改为 %: 2.配置访问数据库的全选 根据需要配置权 ...

  5. canvas一周一练 -- canvas绘制马尾图案 (5)

    运行效果: <!DOCTYPE html> <html> <head> </head> <body> <canvas id=" ...

  6. HDU_1114_piggy-bank

    Piggy-Bank Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit S ...

  7. Functions of the call stack

    https://en.wikipedia.org/wiki/Call_stack#STACK-FRAME As noted above, the primary purpose of a call s ...

  8. DWG转PDF

    DWG转PDF DWG转换PDF有两种方法,一种是利用PDF打印机,一种是利用专业软件: 利用PDF打印机最直接,但是不能批量打印,下面讲一下利用专业软件如何进行批量转换,在这里以梦想CAD软件(Mx ...

  9. 使用TransactionTemplate

    通过TransactionCallback接口中的方法后(这里用来做业务),将返回值传递到TransactionTemplate的execute()中.通过调用TransactionStatus 的s ...

  10. ibatis常用16条SQL语句

    (1) 输入参数为单个值 <delete id="com.fashionfree.stat.accesslog.deleteMemberAccessLogsBefore" p ...