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. ...
随机推荐
- Django CSRF提交遇见的问题
简介 django为用户实现防止跨站请求伪造的功能,通过中间件 django.middleware.csrf.CsrfViewMiddleware 来完成.而对于django中设置防跨站请求伪造功能有 ...
- 【转】Linux中常见问题(磁盘 定时任务)
[转]Linux中常见问题(磁盘 定时任务) 第1章 linux无法上网 1) 第一步,先ping域名. ping www.baidu.com 2)再ping一个公网ip , ping 223 ...
- UML和模式应用4:初始阶段(6)--迭代方法中如何使用用例
1.前言 用例是UP和其他众多迭代方法的核心.UP提倡用例驱动开发. 2. 迭代方法中如何使用用例 功能需求首先定义在用例中 用例是迭代计划的重要部分,迭代是通过选择一些用例场景或整个用例来定义的 用 ...
- 自助Linux之问题诊断工具strace【转】
转自:http://www.cnblogs.com/bangerlee/archive/2012/02/20/2356818.html 引言 “Oops,系统挂死了..." “Oops,程序 ...
- 【转】snprintf()函数使用方法
众所周知,sprintf不能检查目标字符串的长度,可能造成众多安全问题,所以都会推荐使用snprintf. 注:sprintf()函数:int sprintf( char *buffer, const ...
- 如何设置使eclipse修改代码不重启tomcat
tomcat配置 1.server.xml reloadable="true"<Context docBase="ins" path="/ins ...
- centos6 -> zabbix2.2升级3.0.5教程
当然系统版本centos6 清除之前的zabbix的yum源缓存 yum clean all 更换新版本的zabbix的yum源 rpm -qa|grep zabbix rpm -e zabbix-r ...
- Oracle数据库常用Sql语句大全
一,数据控制语句 (DML) 部分 1.INSERT (往数据表里插入记录的语句) INSERT INTO 表名(字段名1, 字段名2, ……) VALUES ( 值1, 值2, ……); INSE ...
- 使用navicat premium将数据库从Oracle迁移到SQL Server,或从Oracle迁移到MySQL
有时候我们有迁移数据库的需求,例如从Oracle迁移到SQL Server,或者从MySQL迁移到Oracle. 很多江湖好汉一时不知如何手工操作,所幸的是Navicat提供了迁移的自动化操作界面. ...
- 浏览器的userAgent归纳
IE IE6 User-Agent:Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.2) IE7 User-Agent:Mozilla/4.0 (compat ...