题目来源: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. Jquery对当前日期的操作(格式化当前日期)

    // 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1-4 个占 ...

  2. ubuntu14.04 安装Kdevelop 进行ROS开发

    1. 安装gcc sudo apt-get build-dep gcc sudo apt-get install build-essential  2. 安装Kdevelop sudo apt-get ...

  3. python顺序执行多个py文件

    python顺序执行多个py文件 假如我要执行code目录下的python程序,假设该目录下有1.py,2.py,3.py,4.py四个文件,但是我想执行1.py,2.py,4.py,则可在该目录下创 ...

  4. Generative Adversarial Nets(原生GAN学习)

    学习总结于国立台湾大学 :李宏毅老师 Author: Ian Goodfellow • Paper: https://arxiv.org/abs/1701.00160 • Video: https:/ ...

  5. lxde 的安装和卸载以及注意事项,lubuntu

    安装: $ sudo apt install lxde $ sudo apt install lxde-common 安装完毕后,可能没法关机及logout,可以使用如下安装: $ sudo apt ...

  6. Salt Document学习笔记1

    原文来自Salt Documentation,作者是 Thomas Hatch),我摘抄部分可能今后会用到或适合入门到精通的一些原文段落,简单翻译后发上来,便于查阅和研究 一.原理方面:The net ...

  7. 转载: 使用vue全家桶制作博客网站 HTML5 移动网站制作的好教程

    使用vue全家桶制作博客网站   前面的话 笔者在做一个完整的博客上线项目,包括前台.后台.后端接口和服务器配置.本文将详细介绍使用vue全家桶制作的博客网站 概述 该项目是基于vue全家桶(vue. ...

  8. 京东在html5页面中打开本地app的解决方案

    转:https://blog.csdn.net/CameloHuang/article/details/64476385 从html5打开本地的app–如果本地没有app就跳转到下载页面,大家都会认为 ...

  9. LeetCode(5):最长回文子串

    Medium! 题目描述: 给定一个字符串 s,找到 s 中最长的回文子串.你可以假设 s 长度最长为1000. 示例: 输入: "babad" 输出: "bab&quo ...

  10. html----属性操作

    1.文本 十六进制值 - 如: #FF0000 一个RGB值 - 如: RGB(255,0,0) 颜色的名称 - 如:  red‘’RGBA() 2.水平对齐方式 text-align 属性规定元素中 ...