快速切题 sgu123. The sum
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的更多相关文章
- 数论 --- 费马小定理 + 快速幂 HDU 4704 Sum
Sum Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=4704 Mean: 给定一个大整数N,求1到N中每个数的因式分解个数的 ...
- 快速切题sgu126. Boxes
126. Boxes time limit per test: 0.25 sec. memory limit per test: 4096 KB There are two boxes. There ...
- 快速切题 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 ...
- 快速切题 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, ...
- 快速切题 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 ...
- 快速切题 acdream手速赛(6)A-C
Sudoku Checker Time Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others) Submi ...
- 快速切题 poj1258
坑!!!我还以为一个整数会截到两行!! Agri-Net Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 40056 Ac ...
- 快速切题 sgu134.Centroid 树形dp
134. Centroid time limit per test: 0.25 sec. memory limit per test: 4096 KB You are given an undirec ...
- 快速切题 poj 1003 hangover 数学观察 难度:0
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 103896 Accepted: 50542 Descr ...
随机推荐
- C# 取form表单的数据
//key代表form表单中html元素的name属性值 public static string StringForm(string key) { string result = null; res ...
- Python3基础 try-多个指定except与不指定except 简单示例
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 pickle.dump和load 对一个对象进行序列化存储及读取
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- c#传统SqlTransaction事务和TransactionScope事务
事务有很多种,看了一些关于事务的问题,这里做下笔记····· 事务时单个的工作单位.如果某一事务成功,则在该事务中进行的所有数据更改均会提交,成为数据库中永久的组成部分.若果事务遇到错误,则必须取消或 ...
- urljoin
from urlparse import urljoin urljoin("http://www.asite.com/folder/currentpage.html", " ...
- python 集合删除元素
#Create a new set num_set = , , , , , ]) #Discard number num_set.discard() print(num_set)
- 【转】Qt在pro中设置运行时库MT、MTd、MD、MDd,只适合VS版本的Qt
http://blog.csdn.net/caoshangpa/article/details/51416077 一.在pro中设置运行时库 最近在用Qt5.6.0(VS2013版本)调用一份用Vis ...
- Qt5.3.2_CentOS6.4_基本编程环境__20160306【勿删,繁琐】
20160306 全程没有f/q ZC:使用的虚拟机环境是:博客园VMwareSkill 的 “CentOS6.4_x86_120g__20160306.rar” 1. 执行命令“gcc -v”,显示 ...
- 《剑指offer》第一题(重载赋值运算符)
//重载赋值运算符 #include <iostream> #include <cstring> using namespace std; class CMystring { ...
- openstack 问题一览(持续总结中)
★名词 Qemu:它也是一种虚拟化技术,主要提供对IO,网络等外设的虚拟化管理.结合KVM(对CPU和内存管理),提供较为完整的虚拟化管理功能. Libvirt:提供了针对各种虚拟机技术的接口,来管理 ...