zoukankan      html  css  js  c++  java
  • codevs1978 Fibonacci数列 3

    题目描述 Description

    斐波纳契数列是这样的数列:

    f1 = 1

    f2 = 1

    f3 = 2

    f4 = 3

    ....

    fn = fn-1 + fn-2

    输入一个整数n

    求fn

    输入描述 Input Description

    一个整数n, n<= 40

    输出描述 Output Description

    一个整数fn

    样例输入 Sample Input

    3

    样例输出 Sample Output

    2

    数据范围及提示 Data Size & Hint

    n<=40

    #include <cstdio>
    int main(){
    	int t[100],n;
    	scanf("%d",&n);
    	t[1]=1;
    	t[2]=1;
    	for(int i=1;i<=40;i++)t[i+2]=t[i]+t[i+1];
    	printf("%d
    ",t[n]);
    	return 0;
    }
  • 相关阅读:
    HDU5873
    HDU5874
    HDU1565(状态压缩dp)
    POJ2774(二分+哈希)
    HDU4474
    HDU2602(背包)
    单链表
    POJ2503(hash)
    POJ1200(hash)
    顺序表
  • 原文地址:https://www.cnblogs.com/codetogether/p/7066336.html
Copyright © 2011-2022 走看看