123. The sum

time limit per test: 0.25 sec. 
memory limit per test: 4096 KB

The Fibonacci sequence of numbers is known: F1 = 1; F2 = 1; Fn+1 = Fn + Fn-1, for n>1. You have to find S - the sum of the first K Fibonacci numbers.

Input

First line contains natural number K (0<K<41).

Output

First line should contain number S.

Sample Input

5

Sample Output

12
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=41;
long long f[maxn];
int main(){
int k;long long s=1;
scanf("%d",&k);f[1]=1;
for(int i=2;i<=k;i++){
f[i]=f[i-1]+f[i-2];
s+=f[i];
}
printf("%I64d\n",s);
return 0;
}

  

快速切题 sgu123. The sum的更多相关文章

  1. 数论 --- 费马小定理 + 快速幂 HDU 4704 Sum

    Sum Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=4704 Mean: 给定一个大整数N,求1到N中每个数的因式分解个数的 ...

  2. 快速切题sgu126. Boxes

    126. Boxes time limit per test: 0.25 sec. memory limit per test: 4096 KB There are two boxes. There ...

  3. 快速切题 sgu118. Digital Root 秦九韶公式

    118. Digital Root time limit per test: 0.25 sec. memory limit per test: 4096 KB Let f(n) be a sum of ...

  4. 快速切题 sgu116. Index of super-prime bfs+树思想

    116. Index of super-prime time limit per test: 0.25 sec. memory limit per test: 4096 KB Let P1, P2, ...

  5. 快速切题 sgu104. Little shop of flowers DP 难度:0

    104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB PROBLEM Yo ...

  6. 快速切题 acdream手速赛(6)A-C

    Sudoku Checker Time Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others) Submi ...

  7. 快速切题 poj1258

    坑!!!我还以为一个整数会截到两行!! Agri-Net Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 40056   Ac ...

  8. 快速切题 sgu134.Centroid 树形dp

    134. Centroid time limit per test: 0.25 sec. memory limit per test: 4096 KB You are given an undirec ...

  9. 快速切题 poj 1003 hangover 数学观察 难度:0

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 103896   Accepted: 50542 Descr ...

随机推荐

  1. Python3基础 函数 可变参数,将传进来的参数转成列表

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  2. Python3基础 str translate 将指定字符转换成另一种特定字符

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  3. 使用CCleaner卸载chrome

    Google Chrome Update Patches Zero-Day Actively Exploited in the Wild 如果有同事使用google Chrome浏览器的话,请检查版本 ...

  4. React Native 的组件之底部导航栏 TabBarIOS(一)

    import React,{Component}from 'react'; import { AppRegistry, StyleSheet, Text, View, TabBarIOS, } fro ...

  5. Python day5_tuple元祖的常见方法1_笔记

    # 初识元祖# 1.元祖的一级元素不能被修改,增加,删除,但可以查看,del tu[0]错的# 2.元祖最后一个元素后注意加‘,’,并没有区别,只是为了和方法中元素区别开li=[11,22,33,44 ...

  6. [ios]ios读写文件本地数据

    参考:http://blog.csdn.net/tianyitianyi1/article/details/7713103 ios - Write写入方式:永久保存在磁盘中.具体方法为:第一步:获得文 ...

  7. [STL][C++]LIST

    参考:http://blog.csdn.net/whz_zb/article/details/6831817 list是双向循环链表,,每一个元素都知道前面一个元素和后面一个元素.在STL中,list ...

  8. (转)c++一些知识点

    异常详解: https://www.cnblogs.com/hdk1993/p/4357541.html#top 模版详解: https://blog.csdn.net/lezardfu/articl ...

  9. 增加centos7.3上安装php7的php-soap扩展

    代码传到正式服务器上去就:Class 'SoapClient' not found,只能是soap扩展没装!    因为服务器上面的PHP是7.1.11的,所以soap也要装7.1.11的,否则会冲突 ...

  10. 15分钟入门lua

    目录:[ - ] -- 1. Variables and flow control. -- 2. Functions. -- 3. Tables. -- 3.1 Metatables and meta ...