由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - interviewstreet 的chanllege #2
相关主题
an openning for System Integration Engineerinterviewstreet上求排列组合的题好像挺多的
刚面完一个三哥这次 InterviewStreet 的 Codesprint 被忽悠了,没几个公司可以申请的
Rocket Fuel一题[InterviewStreet] XOR key (50 Points),请pass的大牛给点思路
shorten url 单机解法 抛砖引玉北京二爷你面过facebook没有?
[ job referral ] 打算申请 FACEBOOK 的进分享个有趣的 onsite
一道题:Vertical Sticks在interviewstreet上做了几题,受打击了
[InterviewStreet] Lego Blocks (50 Points)Facebook的puzzle什么难度呀?
[InterviewStreet] Grid Walking (Score 50 points)interviewstreet的string reduction是不是只能brute force
相关话题的讨论汇总
话题: chanllege话题: number话题: lemma话题: solutions
进入JobHunting版参与讨论
1 (共1页)
c*******n
发帖数: 63
1
http://www.interviewstreet.com
Find the no of positive integral solutions for the equations (1/x) + (1/y) =
1/N! (read 1 by n factorial) Print a single integer which is the no of
positive integral solutions modulo 1000007.
1 <= N <= 10^6
我一开始以为这题单纯是大数运算的问题,后来发现似乎不是
觉得解题的突破点应该是:
let p = n! --> 1/p - 1/(p+k) = k/(p(p+k))
p(p+k)/k is an integer, 1<= k <= p and the total solution of k is the unique
number of products of all combination of [1, n],
that is 1Cn + 2Cn + .... + (n-1)Cn + nCn - redundant products = 2^n -
redundant products
所以问题转成找重复乘积了
比如
6!重复的有 6, 2*3; 3*4, 2*6 等等
想不出什么好思路,各位大牛有没有什么想法
b**********r
发帖数: 91
2
It requires a little bit basic number theory:
The solution of the equation is in the following format:
x=N!+m, y = N!+N!^2/m
where m | (N!)^2
so the total number of solutions are the (number of factors of (N!)^2)-1
(
the minus 1 is for the case x=2*N! and y=2*N!, which is double counted)
Lemma 1: let M = p1^a1*p2*a2*...*pk^ak
where p1, p2, .. pk are distincted prime numbers, a1, a2, ... ak are
positive integers, then the number of factors of M is (a1+1)*(a2+1)*...*
(ak+
1)
Lemma 2: let p be a prime number and p < N, then the largest ap for
p^ap|N!
is the following:
[N/p]+[N/p^2]+....+[N/p^w] where p^w <= N and p^(w+1) > N
where [x] is the integer part of x
Based on the above two lemmas, the algorithms can be implemented in the
following way:
(1) for a given N, find all the prime numbers less or equal to N
(2) For each prime number p obtained from (1), calculate the ap by lemma
2.
then the total number solutions can be obtained with Lemma 1.

(1/y)
=
of
unique

【在 c*******n 的大作中提到】
: http://www.interviewstreet.com
: Find the no of positive integral solutions for the equations (1/x) + (1/y) =
: 1/N! (read 1 by n factorial) Print a single integer which is the no of
: positive integral solutions modulo 1000007.
: 1 <= N <= 10^6
: 我一开始以为这题单纯是大数运算的问题,后来发现似乎不是
: 觉得解题的突破点应该是:
: let p = n! --> 1/p - 1/(p+k) = k/(p(p+k))
: p(p+k)/k is an integer, 1<= k <= p and the total solution of k is the unique
: number of products of all combination of [1, n],

1 (共1页)
进入JobHunting版参与讨论
相关主题
interviewstreet的string reduction是不是只能brute force[ job referral ] 打算申请 FACEBOOK 的进
interviewstreet 明天有个quora专场 感兴趣的童鞋们可以参加试一道题:Vertical Sticks
interviewstreet - kingdom connectivity[InterviewStreet] Lego Blocks (50 Points)
fb一题求解答[InterviewStreet] Grid Walking (Score 50 points)
an openning for System Integration Engineerinterviewstreet上求排列组合的题好像挺多的
刚面完一个三哥这次 InterviewStreet 的 Codesprint 被忽悠了,没几个公司可以申请的
Rocket Fuel一题[InterviewStreet] XOR key (50 Points),请pass的大牛给点思路
shorten url 单机解法 抛砖引玉北京二爷你面过facebook没有?
相关话题的讨论汇总
话题: chanllege话题: number话题: lemma话题: solutions