HackerRank# Fibonacci Modified

原题地址

竟然64位都要爆,这是要大整数乘法的节奏吗?我才不要写大整数乘法呢,用Ruby干掉

代码:

1 # Enter your code here. Read input from STDIN. Print output to STDOUT
2 num = [0, 0]
3 num[0], num[1], n = readline.chomp.split(‘ ‘).map {|e| e.to_i}
4 (n - 2).times do
5     tmp = num[1] ** 2 + num[0]
6     num[0] = num[1]
7     num[1] = tmp
8 end
9 puts num[1]
时间: 2024-08-05 02:52:52

HackerRank# Fibonacci Modified的相关文章

PatentTips - Modified buddy system memory allocation

BACKGROUND Memory allocation systems assign blocks of memory on request. A memory allocation system employs an allocator to receive relatively large blocks of memory from an operating system and allocate that memory to satisfy memory requests. Upon r

Buge's Fibonacci Number Problem

Buge's Fibonacci Number Problem Description snowingsea is having Buge’s discrete mathematics lesson, Buge is now talking about the Fibonacci Number. As a bright student, snowingsea, of course, takes it as a piece of cake. He feels boring and soon com

【转】Fibonacci 斐波纳契堆优化 Dijkstra 最短路径算法

话不多说,拿来主义,直接上代码! PS:打印最短路径我还不晓得怎么加,如有哪位大神知道,还请mark一下! 1 /*********************************************************************** 2 * File: FibonacciHeap.java 3 * Author: Keith Schwarz ([email protected]) 4 * 5 * An implementation of a priority queue

NYOJ 480 Fibonacci Again!

Fibonacci Again! 时间限制:1000 ms  |  内存限制:65535 KB 难度:2 描写叙述 求第n个斐波那契数是否是一个素数,n为整数 f[n]=f[n-1]+f[n-2] (2<n<30) f[1]=3,f[2]=7 输入 输入整数m,0<m<30,输入-1表示结束输入 输出 假设f[m]是素数 则输出Yes,否则输出No, 每行输出占一行. 例子输入 2 3 例子输出 Yes No #include<stdio.h> int f[35]={0

HDU1848 Fibonacci again and again

Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8198    Accepted Submission(s): 3412 Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1)=1;F(2)=2;

The high signification of the modified poplar plywood

What is the modified poplar film faced plywood? This film faced plywood is the new style concrete formwork panel which has the superiority like smooth surface, large format, light weight, high strength, high resistance and can reduce the advantages o

hdu 5167 Fibonacci(DFS)

hdu 5167 Fibonacci 问题描述 斐波那契数列的递归定义如下: Fi=???01Fi?1+Fi?2i = 0i = 1i > 1 现在我们需要判断一个数是否能表示为斐波那契数列中的数的乘积. 输入描述 有多组数据,第一行为数据组数T(T≤100,000). 对于每组数据有一个整数n,表示要判断的数字. 0≤n≤1,000,000,000 输出描述 对于每组数据,如果可以输出"Yes",否则输出"No". 输入样例 3 4 17 233 输出样例

HDU 4099 Revenge of Fibonacci

Revenge of Fibonacci Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 204800/204800 K (Java/Others) Total Submission(s): 2027    Accepted Submission(s): 475 Problem Description The well-known Fibonacci sequence is defined as following: Here w

304 Not Modified

今天在用chrome浏览淘宝页面的时候,发现很多来自淘宝图片HTTP状态码是 304 Not Modified 到百度搜索了一下,明白了 304状态的含义(以下绿色内容来自网络): 304 Not Modified:客户端有缓冲的文件并发出了一个条件性的请求(一般是提供If-Modified-Since头表示客户只想比指定日期更新的文档).服务器告诉客户,原来缓冲的文档还可以继续使用. 如果客户端在请求一个文件的时候,发现自己缓存的文件有 Last Modified ,那么在请求中会包含 If