题目来源: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的更多相关文章

  1. HackerRank# Fibonacci Modified

    原题地址 竟然64位都要爆,这是要大整数乘法的节奏吗?我才不要写大整数乘法呢,用Ruby干掉 代码: # Enter your code here. Read input from STDIN. Pr ...

  2. Buge's Fibonacci Number Problem

    Buge's Fibonacci Number Problem Description snowingsea is having Buge’s discrete mathematics lesson, ...

  3. PatentTips - Modified buddy system memory allocation

    BACKGROUND Memory allocation systems assign blocks of memory on request. A memory allocation system ...

  4. The best Fibonacci is achieved in js

    The best Fibonacci is achieved in js the best realized by using js 斐波那契数列 "use strict"; /* ...

  5. fibonacci number & fibonacci sequence

    fibonacci number & fibonacci sequence https://www.mathsisfun.com/numbers/fibonacci-sequence.html ...

  6. fibonacci all in one

    fibonacci all in one fibonacci sequence https://www.mathsisfun.com/numbers/fibonacci-sequence.html f ...

  7. 算法与数据结构(九) 查找表的顺序查找、折半查找、插值查找以及Fibonacci查找

    今天这篇博客就聊聊几种常见的查找算法,当然本篇博客只是涉及了部分查找算法,接下来的几篇博客中都将会介绍关于查找的相关内容.本篇博客主要介绍查找表的顺序查找.折半查找.插值查找以及Fibonacci查找 ...

  8. 为什么你SQL Server的数据库文件的Date modified没有变化呢?

    在SQL Server数据库中,数据文件与事务日志文件的修改日期(Date Modified)是会变化的,但是有时候你会发现你的数据文件或日志文件的修改日期(Date Modified)几个月甚至是半 ...

  9. #26 fibonacci seqs

    Difficulty: Easy Topic: Fibonacci seqs Write a function which returns the first X fibonacci numbers. ...

随机推荐

  1. Responsive响应式设计

    在IE6-8中完全是不支持CSS3 Media Queries的.那么为了让IE6-8支持,我们就很有必要的在IE9以下的浏览器中加上media-queries.js或者respond.js脚本: & ...

  2. Debian & CentOS建立本地iso源

    在宿舍搞开发的时候经常遇到有些工具需要安装,没有网络,这时候只能靠mount本地的iso镜像来搞,结果像Debian有3张安装光盘,CentOS有2张光盘,有时候安装包不在第一张光盘里,而在第二张光盘 ...

  3. 2018-2019-2 网络对抗技术 20165320 Exp2 后门原理与实践

    后门原理与实践 windows获取Linux操作Shell 获取本机的IP netcat介绍:一个进行基本的TCP.UDP数据收发的工具 相关的参数与具体用法 windows打开监听: ncat.ex ...

  4. Java读取Txt封装到对象中——(三)

    JavaBean package bean; public class Question { private String timu; //题干 private String leixing; //类 ...

  5. if-else 重构

    最近发现自己写的代码if else太多了,有时候自己回头看都要重新捋逻辑,很不好.决定深入理解下if else重构. 中心思想: ①不同分支应当是同等层次,内容相当. ②合并条件表达式,减少if语句数 ...

  6. 【转载】apache log配置 按日期写日志

    指定apache日志每天生成一个文件 Linux系统配置方法 在apache的配置文件httpd.conf中找到 代码如下1 ErrorLog logs/error_log CustomLog log ...

  7. ES系列十七、logback+ELK日志搭建

    一.ELK应用场景 在复杂的企业应用服务群中,记录日志方式多种多样,并且不易归档以及提供日志监控的机制.无论是开发人员还是运维人员都无法准确的定位服务.服务器上面出现的种种问题,也没有高效搜索日志内容 ...

  8. 005_nginx414_nginx 414 Request-URI Too Large

    一.开发请求一个非常长的请求参数 https://jiaju.jyall.me/backend/dish/getSales/?dishId=167271&dishId=166975&d ...

  9. 转 利用 Console 来学习、调试JavaScript

    利用 Console 来学习.调试JavaScript   一  什么是 Console Console 是用于显示 JS和 DOM 对象信息的单独窗口.并且向 JS 中注入1个 console 对象 ...

  10. 解决LoggerFactory is not a Logback LoggerContext but Logback is on the classpath

    因为引用了log4j2同时还引用了logback