hpuoj【1055】斐波那契
来源:互联网 发布:js设置div颜色 编辑:程序博客网 时间:2024/04/30 11:51
1055: 斐波那契 [水题]
时间限制: 1 Sec 内存限制: 128 MB提交: 252 解决: 106
题目描述
Do you know the Fibonacci sequence?
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones:
1、1、2、3、5、8、13、21……
The sequence Fn of Fibonacci numbers is defined by the recurrence relation:
Give you a positive integer
.
输入
Input includes multiple cases.
Each line is a positive integer
.
输出
For each case:
Print a integer number in a line, is the
.
样例输入
234
样例输出
123
程序如下:
#include<cstdio>int main(){int n;while(scanf("%d",&n)!=EOF){int a[50],i;a[1]=a[2]=1;if(n==1||n==2) printf("1\n");else{for(i=3;i<=n;i++) a[i]=a[i-1]+a[i-2]; printf("%d\n",a[n]);}}return 0;}
阅读全文
0 0
- hpuoj【1055】斐波那契
- hpuoj【1444】斐波那契数列&& 【找规律】
- hpuoj--1287--HH实习(斐波那契数巧用)
- **【HPUOJ】
- 斐波那契
- 斐波那契
- 斐波那契
- 斐波那契
- 斐波那契
- 斐波那契
- 斐波那契
- 斐波那契
- 【斐波那契】
- 斐波那契
- 斐波那契
- 斐波那契
- 斐波那契
- 斐波那契
- 【SIKI】_06_Unity2D游戏开发-拾荒者笔记
- ucos,软件定时器。自己理解
- 单例模式
- 关于Vue.js 组件的使用及其概念
- Java日期时间及其格式化
- hpuoj【1055】斐波那契
- version magic 不一致问题
- 傅里叶变换分析
- 百练_2911:受限完全平方数
- 笔试题分析(1)
- 启用shareding认证
- Oracle数据库sqlplus常用命令
- 线性代数 矩阵乘法
- 比较全的spring约束