由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 分享一道trading firm的code screen,只能用c++
相关主题
dynamic programming的一点疑问DP interview question
一道算法题目问道题: numbers of distinct substring
A公司的面经EDA职位
问个算法题之被dynamic programming打败了Financial IT contractor opening - 5+ years C++/STL
实在理解不了DP、图论等题,可以死记硬背么?Data Operations opportunity
一道面试题求解Ask for internship refer, statistics background
Fibonacci数计算 要求constant time急问有没有面试过bloomberg的senior calculations programmer的?
面试被问了这样一道题about how to test a calculator program on computer
相关话题的讨论汇总
话题: fibonacci话题: prime话题: dp话题: fn话题: calculate
进入JobHunting版参与讨论
1 (共1页)
s*****e
发帖数: 115
1
Please take 60 minutes to work on this and send it back to me when you are
done. The test must be done in C++ and you must do a recursive solution.
/**
* The Fibonacci sequence is Fn = Fn-1 + Fn-2. Seed values F0=0, F1=1.
* Example: 0+1=1, 1+1=2, 1+2=3, 2+3=5, 3+5=8, ...
* Write a program that calculates the Fibonacci sequence, and then returns
all primes up to the nth prime Fibonacci number, where n is an
* option passed in on the cmd line.
* Example: In the above calculation - prime_fib 3 -> 2 3 5
* If a non-integer value is passed in on the command line, you should print
a statement " is not a number" as an error output, and then continue
processing data.
*
* ./prime_fibs 1 2 7 foo 5
* calculate the first 1 prime fibonacci numbers.
* 2
* calculate the first 2 prime fibonacci numbers.
* 2 3
* calculate the first 7 prime fibonacci numbers.
* 2 3 5 13 89 233 1597
* foo is not a number.
* calculate the first 5 prime fibonacci numbers.
* 2 3 5 13 89
*
*/
诸位看官,一个小时要做出来,这是要几年的经验才能不用准备就能做出来?
我当时做的时候,prime这个公式可以马上google出来,fibonacci这个我第一时间想到
是DP, RECURSION的话有两种,不带DP的recursion,2年前我实现过,n只能到大约37
, 带DP的recursion不见得比纯DP要好啊?
我当时想做到one pass,多想一会,时间就过了,还是自己功力不够
k******n
发帖数: 184
2
这题要用到一点同余知识推出一个比较简单的关于项数i和值结论
感觉考点就是高中奥数。。。╮(╯▽╰)╭
l***i
发帖数: 1309
3
fibo numbers grow very fast, so n is very small.
t****b
发帖数: 2484
4
分别对每个数求是不是素数
用二分也是常数复杂度吧
w*******d
发帖数: 59
5
真的假的……现在数学家还不知道是不是有无穷多 fibonacci primes...... 唯一有用
的结论大概就是Fibonacci prime对应的n一定是prime,然后用筛法找吧……

【在 k******n 的大作中提到】
: 这题要用到一点同余知识推出一个比较简单的关于项数i和值结论
: 感觉考点就是高中奥数。。。╮(╯▽╰)╭

s**x
发帖数: 7506
6
30 min is enough
G***G
发帖数: 16778
7
easy
first Fibonacci sequence
then check if it is prime

returns
print

【在 s*****e 的大作中提到】
: Please take 60 minutes to work on this and send it back to me when you are
: done. The test must be done in C++ and you must do a recursive solution.
: /**
: * The Fibonacci sequence is Fn = Fn-1 + Fn-2. Seed values F0=0, F1=1.
: * Example: 0+1=1, 1+1=2, 1+2=3, 2+3=5, 3+5=8, ...
: * Write a program that calculates the Fibonacci sequence, and then returns
: all primes up to the nth prime Fibonacci number, where n is an
: * option passed in on the cmd line.
: * Example: In the above calculation - prime_fib 3 -> 2 3 5
: * If a non-integer value is passed in on the command line, you should print

G****A
发帖数: 4160
8
每找到一个Fibonacci number立刻check prime, check prime需要用memorization

returns
print

【在 s*****e 的大作中提到】
: Please take 60 minutes to work on this and send it back to me when you are
: done. The test must be done in C++ and you must do a recursive solution.
: /**
: * The Fibonacci sequence is Fn = Fn-1 + Fn-2. Seed values F0=0, F1=1.
: * Example: 0+1=1, 1+1=2, 1+2=3, 2+3=5, 3+5=8, ...
: * Write a program that calculates the Fibonacci sequence, and then returns
: all primes up to the nth prime Fibonacci number, where n is an
: * option passed in on the cmd line.
: * Example: In the above calculation - prime_fib 3 -> 2 3 5
: * If a non-integer value is passed in on the command line, you should print

1 (共1页)
进入JobHunting版参与讨论
相关主题
about how to test a calculator program on computer实在理解不了DP、图论等题,可以死记硬背么?
怎么准备bloomberg电面?一道面试题求解
谁有C++ Prime 4th Edition的习题答案吗?Fibonacci数计算 要求constant time
Fibonacci序列的时间和空间复杂度是多少呀?面试被问了这样一道题
dynamic programming的一点疑问DP interview question
一道算法题目问道题: numbers of distinct substring
A公司的面经EDA职位
问个算法题之被dynamic programming打败了Financial IT contractor opening - 5+ years C++/STL
相关话题的讨论汇总
话题: fibonacci话题: prime话题: dp话题: fn话题: calculate