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. JavaScript(七)数组

    Array类型 1.创建数组 字面量 var arr = [];//不要在低版本的浏览其中创建字面量的时候最后 //一个item后面加 逗号 低版本会 再新建一个空的item 构造函数 var arr ...

  2. git 分支处理

    git 创建常用(多)分支(如:Master 主分支.Develop 分.Feature 功能分支.Release 预发布分支.Hotfix(或者Fixbug) 分支)步骤1.mkdir 项目名    ...

  3. 隐藏win10任务栏输入法M图标

    在任务栏右键=>任务栏设置=>打开或关闭系统图标=>(关闭)输入指示

  4. 安卓app测试之Monkeyscript

    MonkeyScript是一组可以被Monkey识别的命令集合 优点:MonkeyScript可以完成重复固定的操作 使用:adb shell monkey -f <scriptfile> ...

  5. Shell printf命令

    Shell 的另一个输出命令 printf.默认 printf 不会像 echo 自动添加换行符,我们可以手动添加 \n. #!/bin/bash printf "%-10s %-8s %- ...

  6. JAVA程序员面试笔试宝典4

    1.HTTP中GET与POST方法有什么区别? GET方法上传数据时,数据添加在URL后面.同时,数据大小有限制,通常在1024Byte左右.POST方法传递数据是通过HTTP请求的附件进行的,传递的 ...

  7. NOIP2000方格取数(洛谷,动态规划递推)

    先上题目: P1004 方格取数 下面上ac代码: ///如果先走第一个再走第二个不可控因素太多 #include<bits/stdc++.h> #define ll long long ...

  8. MySQL数据导入sql文件过程中出错

    错误类型: ERROR 1231 (42000): Variable 'time_zone' can't be set to the value of 'NULL' ERROR 1231 (42000 ...

  9. 创建和获取cookie

    创建和获取cookie 制作人:全心全意 cookie:在互联网中,cookie是小段的文本信息,在网络服务器上生成,并发送给浏览器.通过使用cookie可以标识用户身份,记录用户名和密码,跟踪重复用 ...

  10. 03 Python的那些事

    目录: 1) 创始人以及重要发展历程 2) Python语言的特点 3) TIOBE排名 4) 解释器 5) Python后缀名 6) 变量规则和约定 7) 常量 8) 注释 9) 缩进 10) Py ...