Fibonacci Modified
题目来源:Fibonacci Modified
We define a modified Fibonacci sequence using the following definition:
Given terms and where , term is computed using the following relation:
For example, if term and , term , term , term , and so on.
Given three integers, , , and , compute and print term of a modified Fibonacci sequence.
Note: The value of may far exceed the range of a -bit integer. Many submission languages have libraries that can handle such large results but, for those that don't (e.g., C++), you will need to be more creative in your solution to compensate for the limitations of your chosen submission language.
Input Format
A single line of three space-separated integers describing the respective values of , , and .
Constraints
- may far exceed the range of a -bit integer.
Output Format
Print a single integer denoting the value of term in the modified Fibonacci sequence where the first two terms are and .
Sample Input
0 1 5
Sample Output
5
Explanation
The first two terms of the sequence are and , which gives us a modified Fibonacci sequence of . Because , we print term , which is .
偷懒的Python版本:
in_str = raw_input() pre, aft, num = map(int, in_str.split()) for i in range(num-2):
pre, aft = aft, pre + aft**2 print aft
Fibonacci Modified的更多相关文章
- HackerRank# Fibonacci Modified
原题地址 竟然64位都要爆,这是要大整数乘法的节奏吗?我才不要写大整数乘法呢,用Ruby干掉 代码: # Enter your code here. Read input from STDIN. Pr ...
- Buge's Fibonacci Number Problem
Buge's Fibonacci Number Problem Description snowingsea is having Buge’s discrete mathematics lesson, ...
- PatentTips - Modified buddy system memory allocation
BACKGROUND Memory allocation systems assign blocks of memory on request. A memory allocation system ...
- The best Fibonacci is achieved in js
The best Fibonacci is achieved in js the best realized by using js 斐波那契数列 "use strict"; /* ...
- fibonacci number & fibonacci sequence
fibonacci number & fibonacci sequence https://www.mathsisfun.com/numbers/fibonacci-sequence.html ...
- fibonacci all in one
fibonacci all in one fibonacci sequence https://www.mathsisfun.com/numbers/fibonacci-sequence.html f ...
- 算法与数据结构(九) 查找表的顺序查找、折半查找、插值查找以及Fibonacci查找
今天这篇博客就聊聊几种常见的查找算法,当然本篇博客只是涉及了部分查找算法,接下来的几篇博客中都将会介绍关于查找的相关内容.本篇博客主要介绍查找表的顺序查找.折半查找.插值查找以及Fibonacci查找 ...
- 为什么你SQL Server的数据库文件的Date modified没有变化呢?
在SQL Server数据库中,数据文件与事务日志文件的修改日期(Date Modified)是会变化的,但是有时候你会发现你的数据文件或日志文件的修改日期(Date Modified)几个月甚至是半 ...
- #26 fibonacci seqs
Difficulty: Easy Topic: Fibonacci seqs Write a function which returns the first X fibonacci numbers. ...
随机推荐
- mac系统在配置navicat时连接数据的时候提示can't connect to mysql server on '127.0.0.1'
新建数据库连接的时候,将默认的端口号更改掉,改为3307,即可解决这个问题. 具体是为什么我也不清楚,我自己想的一个可能就是mac电脑 上的某个程序可能已经占用了3306那个默认的端口,因 ...
- L0/L1/L2范数(转载)
一.首先说一下范数的概念: 向量的范数可以简单形象的理解为向量的长度,或者向量到零点的距离,或者相应的两个点之间的距离. 向量的范数定义:向量的范数是一个函数||x||,满足非负性||x|| > ...
- CentOS配置SSH无密码
210-211/212/213的集群中,新增215节点,操作:1.将210的id_rsa.pub拷贝到215中:scp ~/.ssh/id_rsa.pub 192.168.0.215@host:/ho ...
- TCP建立流程 【转】
解决TCP连接数过多的问题 TCP状态迁移,CLOSE_WAIT & FIN_WAIT2 的问题 TCP状态迁移 大家对netstat -a命令很熟悉,但是,你有没有注意到STATE一栏呢,基 ...
- linux更换yum源
由于 redhat的yum在线更新是收费的,如果没有注册的话不能使用,如果要使用,需将redhat的yum卸载后,重启安装,再配置其他源,以下为详细过程: 1.删除redhat原有的yum rpm - ...
- 转载:Linux操作系统(1.3.1)《深入理解Nginx》(陶辉)
原文:https://book.2cto.com/201304/19611.html 1.3 准备工作 由于Linux具有免费.使用广泛.商业支持越来越完善等特点,本书将主要针对Linux上运行的Ng ...
- shell脚本收集服务器基本信息并入库
# cat check_all.sh #!/bin/bash #create by hexm @2016.6 #date=`date +%Y%m%d` #DIST_FILE=/app/healthch ...
- ajax post 传参数加引号和不加引号的区别
1.前言 用ajax技术,type:post,data:参数列表.参数列表就是一个JSON数据,但key可以加引号,也可以不加引号,那总有区别的. 2.区别 var d2 = "two&qu ...
- Protocol Buffers简明教程
随着微服务架构的流行,RPC框架渐渐地成为服务框架的一个重要部分. 在很多RPC的设计中,都采用了高性能的编解码技术,Protocol Buffers就属于其中的佼佼者. Protocol Buffe ...
- 用java实现邮件发送验证码
java实现邮件发送验证码 建议不要用qq邮箱,我使用qq邮箱直接一直给我报530错误,我一直认为我代码写的有错误或者POP3/SMTP服务没弄好.所以建议注册个别的邮箱,我就申请了个网易163邮箱瞬 ...