由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问一道古老的面试题
相关主题
MS on-site狗家实习面试题
问一道题请教一道随机数生成器的面试题
关于DP的问题面试题大整数互质求和
面试题库除了careercup还有哪里有?有这样的东西么(描述见内)分享个面试题
Amazon二面结束,求BLESS问一道面试题,关于大数据如何高效找出median数
请问一道面试题问一道面试题
这类和数学有关的面试题怎么解决?FLG面试题,压缩整数 (转载)
高通 面试题 疑问。。问道面试题,关于bst的
相关话题的讨论汇总
话题: 能行话题: improve话题: prob话题: generate话题: twice
进入JobHunting版参与讨论
1 (共1页)
t*****y
发帖数: 31
1
利用能生成1-6随机整数的函数,如何构造生成1-7随机整数的函数。
怎么做呢? 谢谢
s*x
发帖数: 3328
2
生成7个随机数,然后除以六。

【在 t*****y 的大作中提到】
: 利用能生成1-6随机整数的函数,如何构造生成1-7随机整数的函数。
: 怎么做呢? 谢谢

t*****y
发帖数: 31
3
7个相加除以6,分布会变掉吧?
a**********s
发帖数: 588
4
generate 1-6 twice, then map pairs to 1-7:
(1, 1) .... (1, 5) --------> 1
(1, 6) .... (2, 4) --------> 2
(2, 5) .... (3, 3) --------> 3
(3, 4) .... (4, 2) --------> 4
(4, 3) .... (5, 1) --------> 5
(5, 2) .... (5, 6) --------> 6
(6, 1) .... (6, 5) --------> 7
(6, 6) -------------------> do it again
t*****y
发帖数: 31
5
make sense
谢谢美女!

【在 a**********s 的大作中提到】
: generate 1-6 twice, then map pairs to 1-7:
: (1, 1) .... (1, 5) --------> 1
: (1, 6) .... (2, 4) --------> 2
: (2, 5) .... (3, 3) --------> 3
: (3, 4) .... (4, 2) --------> 4
: (4, 3) .... (5, 1) --------> 5
: (5, 2) .... (5, 6) --------> 6
: (6, 1) .... (6, 5) --------> 7
: (6, 6) -------------------> do it again

f**e
发帖数: 1269
6
同上前围观美女!

【在 t*****y 的大作中提到】
: make sense
: 谢谢美女!

l***e
发帖数: 480
7
X^2/Y
c******a
发帖数: 198
8

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~这个能行?

【在 a**********s 的大作中提到】
: generate 1-6 twice, then map pairs to 1-7:
: (1, 1) .... (1, 5) --------> 1
: (1, 6) .... (2, 4) --------> 2
: (2, 5) .... (3, 3) --------> 3
: (3, 4) .... (4, 2) --------> 4
: (4, 3) .... (5, 1) --------> 5
: (5, 2) .... (5, 6) --------> 6
: (6, 1) .... (6, 5) --------> 7
: (6, 6) -------------------> do it again

z****e
发帖数: 2024
9
your way works and is fine. But we can still improve it.
1. there is a waste (6,6), as you see, you have to do it over again.
2. order dependency. The first time to throw the dice and second time is
different. ie (3,4) and (4,3) map to different numbers.
There is a way to improve and remove the previous 2 drawbacks.
generate 1-6 twice and get a 6*6 table. fold your table along the diagonal
line (upper-left to lower-right).
Now you have 21 elements which is 3*7, and there is no order dependency
a

【在 a**********s 的大作中提到】
: generate 1-6 twice, then map pairs to 1-7:
: (1, 1) .... (1, 5) --------> 1
: (1, 6) .... (2, 4) --------> 2
: (2, 5) .... (3, 3) --------> 3
: (3, 4) .... (4, 2) --------> 4
: (4, 3) .... (5, 1) --------> 5
: (5, 2) .... (5, 6) --------> 6
: (6, 1) .... (6, 5) --------> 7
: (6, 6) -------------------> do it again

g*******y
发帖数: 1930
10
inequal probability. prob(i,j)+prob(j,i) = 2*prob(i,i)
actually in this very problem, you cannot improve, since (6*6) % 7 = 1
if the mod is >=2, then there's a chance to improve.

【在 z****e 的大作中提到】
: your way works and is fine. But we can still improve it.
: 1. there is a waste (6,6), as you see, you have to do it over again.
: 2. order dependency. The first time to throw the dice and second time is
: different. ie (3,4) and (4,3) map to different numbers.
: There is a way to improve and remove the previous 2 drawbacks.
: generate 1-6 twice and get a 6*6 table. fold your table along the diagonal
: line (upper-left to lower-right).
: Now you have 21 elements which is 3*7, and there is no order dependency
: a

1 (共1页)
进入JobHunting版参与讨论
相关主题
问道面试题,关于bst的Amazon二面结束,求BLESS
来问一道面试题,除以很大的数请问一道面试题
问个随机数的问题这类和数学有关的面试题怎么解决?
这个题没怎么看大家讲过高通 面试题 疑问。。
MS on-site狗家实习面试题
问一道题请教一道随机数生成器的面试题
关于DP的问题面试题大整数互质求和
面试题库除了careercup还有哪里有?有这样的东西么(描述见内)分享个面试题
相关话题的讨论汇总
话题: 能行话题: improve话题: prob话题: generate话题: twice