题目描述

输入一个正整数n,求Fibonacci数列的第n个数。Fibonacci数列的特点:第1,2个数为1,1。从第3个数开始,概述是前面两个数之和。即:

1,1,2,3,5,8,13,21 …

要求输入的正整数n不超过50.

输入

一个不超过50的正整数

输出

Fibonacci数列的第n个数,末尾输出换行。

样例输入 Copy

20

样例输出 Copy

6765

#include <stdio.h>
#include <stdlib.h>
int main()
{
int i=1,j=1,n,seq,num=1;
scanf("%d",&n);
if(n==1&&n==2){
printf("%d\n",num);
}else{
for(seq=3;seq<=n;seq++){
num=i+j;
i=j;
j=num;
} //1 1 2 3 5 8 13 21
printf("%d\n",num);
}
return 0;
}

Codeup 25594 Problem H 例题5-8 Fibonacci数列的更多相关文章

  1. Codeup 25593 Problem G 例题5-7 求圆周率pi的近似值

    题目描述 用如下公式 4*Π = 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + 1/13 - 1/15 - 求圆周率PI的近似值,直到发现某一项的绝对值小于10-6为止(该项不 ...

  2. 实验12:Problem H: 整型数组运算符重载

    Home Web Board ProblemSet Standing Status Statistics   Problem H: 整型数组运算符重载 Problem H: 整型数组运算符重载 Tim ...

  3. The Ninth Hunan Collegiate Programming Contest (2013) Problem H

    Problem H High bridge, low bridge Q: There are one high bridge and one low bridge across the river. ...

  4. Gym 100531H Problem H. Hiking in the Hills 二分

    Problem H. Hiking in the Hills 题目连接: http://codeforces.com/gym/100531/attachments Description Helen ...

  5. Codeforces Gym 100610 Problem H. Horrible Truth 瞎搞

    Problem H. Horrible Truth Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1006 ...

  6. Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉

    Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...

  7. 清北学堂入学测试P4751 H’s problem(h)

    P4751 H’s problem(h)  时间: 1000ms / 空间: 655360KiB / Java类名: Main 背景 冬令营入学测试 描述 小H是一个喜欢逛街的女孩子,但是由于上了大学 ...

  8. Problem H

    Problem Description 穿过幽谷意味着离大魔王lemon已经无限接近了! 可谁能想到,yifenfei在斩杀了一些虾兵蟹将后,却再次面临命运大迷宫的考验,这是魔王lemon设下的又一个 ...

  9. 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem H. Password Service dp

    Problem H. Password Service 题目连接: http://www.codeforces.com/gym/100253 Description Startups are here ...

随机推荐

  1. Natas21 Writeup(共用session、session注入)

    Natas21: 第一个网页 第二个网页 提示http://natas21.natas.labs.overthewire.org/页面和http://natas21-experimenter.nata ...

  2. Natas11 Writeup(常见编码、异或逆推、修改cookie)

    Natas11: 页面提示cookie被异或加密保护,查看源码,发现了一个预定义参数和三个函数. //预定义参数,猜测将showpassword设置为yes即可得到密码. $defaultdata = ...

  3. Mol Cell Proteomics. | Identification of salivary biomarkers for oral cancer detection with untargeted and targeted quantitative proteomics approaches (解读人:卜繁宇)

    文献名:Identification of salivary biomarkers for oral cancer detection with untargeted and targeted qua ...

  4. 第七周java实验作业

    实验七 继承附加实验实验时间 2018-10-11 1.实验目的与要求 (1)进一步理解4个成员访问权限修饰符的用途: Public  该类或非该类均可访问 Private  只有该类可以访问 Pro ...

  5. Manjaro更新后 搜狗拼音输入法突然无法正常使用

    之前Manjaro已经用了很久了,很多该配置的都已经配置好了,但是搜狗拼音在系统更新后突然无法使用 1检查 如下依赖 2.检查配置文件 3.发现一切配置没问题,此时输入 sogou-qimpanel ...

  6. mysql-8.0.19-winx64下载

    mysql-8.0.19-winx64 下载链接 提取码:m7qp

  7. Springboot CORS跨域访问

    Springboot CORS跨域访问 什么是跨域 浏览器的同源策略限制: 它是浏览器最核心也最基本的安全功能,如果缺少了同源策略,则浏览器的正常功能可能都会受到影响.可以说Web是构建在同源策略基础 ...

  8. 50行代码实现GAN | 干货演练

    2014年,Ian Goodfellow和他的同事发表了一篇论文,向世界介绍了生成对抗网络(GAN).通过对计算图和博弈论的创新性组合,他们表明如果有足够的建模能力,两个相互对抗的模型可以通过普通的反 ...

  9. 从阿里、腾讯的面试真题中总结了这11个Redis高频面试题

    前言 现在大家的工作生活基本已经是回归正轨了,最近也是迎来了跳槽面试季,有些人已经拿到了一两个offer了. 这段时间收集了阿里.腾讯.百度.京东.美团.字节跳动等公司的Java面试题,总结了Redi ...

  10. vs编译器中不允许使用scanf()的情况

    问题1描述: vs编译器中,不允许使用scanf()函数. error C4996: 'scanf': This function or variable may be unsafe. Conside ...