Fibbonacci Number

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

Total Submission(s): 13400    Accepted Submission(s): 6677

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<stdio.h>
__int64 a[55]={0,1};
int main()
{
int i;
int m;
for(i=2;i<51;i++)
a[i]=a[i-1]+a[i-2];
while(scanf("%d",&m)&&(m!=-1))
{
printf("%I64d\n",a[m]);
}
return 0;
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

HDU 2070 Fibbonacci Number的更多相关文章

  1. HDUJ 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. hdu 5898 odd-even number 数位DP

    传送门:hdu 5898 odd-even number 思路:数位DP,套着数位DP的模板搞一发就可以了不过要注意前导0的处理,dp[pos][pre][status][ze] pos:当前处理的位 ...

  5. hdu 2665 Kth number

    划分树 /* HDU 2665 Kth number 划分树 */ #include<stdio.h> #include<iostream> #include<strin ...

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

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

  7. hdu 4670 Cube number on a tree(点分治)

    Cube number on a tree Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/ ...

  8. 主席树[可持久化线段树](hdu 2665 Kth number、SP 10628 Count on a tree、ZOJ 2112 Dynamic Rankings、codeforces 813E Army Creation、codeforces960F:Pathwalks )

    在今天三黑(恶意评分刷上去的那种)两紫的智推中,突然出现了P3834 [模板]可持久化线段树 1(主席树)就突然有了不详的预感2333 果然...然后我gg了!被大佬虐了! hdu 2665 Kth ...

  9. 2Q - Fibbonacci Number

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

随机推荐

  1. Shuttle ESB(四)——宣布订阅模式实例介绍(1)

    前,我的重点是关注的三篇文章Shuttle ESB入境和宏观的概念范例. Shuttle ESB模式:请求/对应模式与Pub/Sub模式. 关于这两种模式的区分,请看以下文章的介绍:Shuttle E ...

  2. nyoj 题号12 水厂(两)——南阳oj

    标题信息: 喷水装置(二) 时间限制:3000 ms  |  内存限制:65535 KB 难度:4 描写叙述 有一块草坪.横向长w,纵向长为h,在它的橫向中心线上不同位置处装有n(n<=1000 ...

  3. 在 Swift 语言中更好的处理 JSON 数据:SwiftyJSON

    SwiftyJSON能够让在Swift语言中更加简便处理JSON数据. With SwiftyJSON all you have to do is: ? 1 2 3 4 let json = JSON ...

  4. Golang+Mongodb

    Golang+Mongodb打造你的第一个站点 很多人推荐MEAN来开发站点.MEAN就是M:mongodb,E:expressjs.A:angular最后的N:nodejs. 但是如果你亲身的体会到 ...

  5. CodeForces 482C Game with Strings

    意甲冠军: n一定长度m串  隐藏的字符串相等的概率  然后,你猜怎么着玩家隐藏的字符串  的询问字符串的一个位置  再不断的知道一些位置后  游戏者就能够确定藏起来的串是什么  问  游戏者的期望步 ...

  6. Ubuntu 下一个disk清理保护

    有很长一段时间ubuntu人,很多人会突然提示:磁盘空间不足1G. 然后很长一段时间分析..最近遇到的类别似问题.记录,如下面: 一个:.xsession-errors.old 能够在终端看到主用户文 ...

  7. RH253读书笔记(4)-Lab 4 The Domain Name System

    Lab 4 The Domain Name System Goal: To install and configure a DNS server System Setup: Throughout th ...

  8. API访问客户端

    API访问客户端(WebApiClient适用于MVC/WebForms/WinForm) 这几天没更新主要是因为没有一款合适的后端框架来支持我们的Web API项目Demo, 所以耽误了几天, 目前 ...

  9. hdu1115(重力算法的多边形中心)

    标题的含义: 给定一个n刚n顶点.这是获得n分众协调多边形. http://acm.hdu.edu.cn/showproblem.php? pid=1115 题目分析: /** *出处:http:// ...

  10. boostrap-非常好用但是容易让人忽略的地方------modal

    使用bootstrap框架好久了,在开发中也用到了或者遇到了很多的问题,所以跟大家分享一下 bootstrap modal 组件的样式 .modal-lg .modal-sm 说明:这个是bootst ...