由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问一道 Interviewstreet 上的题 (JAVA)
相关主题
求教EA一道面试题leecode上的divide two integers问题
贡献个面试题,目前狗狗都没找到.....两整数相除问题
Divide Two Integers关于Divide a integer
问一个facebook的电面题leetcode: Divide Two Integers 怎么做?
关于除法的问题Divide Two Integers Answer 超时
计算乘法和除法,不用乘法和除法符号,怎么scaledivide two integers
两个整数除法的问题太刁钻了吧M 家电面
leetcode上的2个整数相除Divide Two Integers OJ和CCP150的做法
相关话题的讨论汇总
话题: unfriendly话题: numbers话题: divide话题: number话题: java
进入JobHunting版参与讨论
1 (共1页)
N*********S
发帖数: 51
1
看来找工作不练练算法不行啊....
Using Java:
https://www.interviewstreet.com/challenges/dashboard/#problem/4f7272a8b9d15
There is one friendly number and N unfriendly numbers. We want to find how
many numbers are there which exactly divide the friendly number, but does
not divide any of the unfriendly numbers.
Input Format:
The first line of input contains two numbers N and K seperated by spaces. N
is the number of unfriendly numbers, K is the friendly number.
The second line of input contains N space separated unfriendly numbers.
Output Format:
Output the answer in a single line.
Constraints:
1 <= N <= 10^6
1 <= K <= 10^13
1 <= unfriendly numbers <= 10^18
Sample Input:
8 16
2 5 7 4 3 8 3 18
Sample Output:
1
Explanation :
Divisors of the given friendly number 16, are { 1, 2, 4, 8, 16 } and the
unfriendly numbers are {2, 5, 7, 4, 3, 8, 3, 18}. Now 1 divides all
unfriendly numbers, 2 divide 2, 4 divide 4, 8 divide 8 but 16 divides none
of them. So only one number exists which divide the friendly number but does
not divide any of the unfriendly numbers. So the answer is 1.
c********t
发帖数: 5706
2
这个题除了brute force, O(N^2),还有别的解法吗?

4f7272a8b9d15
N

【在 N*********S 的大作中提到】
: 看来找工作不练练算法不行啊....
: Using Java:
: https://www.interviewstreet.com/challenges/dashboard/#problem/4f7272a8b9d15
: There is one friendly number and N unfriendly numbers. We want to find how
: many numbers are there which exactly divide the friendly number, but does
: not divide any of the unfriendly numbers.
: Input Format:
: The first line of input contains two numbers N and K seperated by spaces. N
: is the number of unfriendly numbers, K is the friendly number.
: The second line of input contains N space separated unfriendly numbers.

t********g
发帖数: 33
3
同文,如果是brute force是不是复杂度应该是O(N*K^0.5)?
1 (共1页)
进入JobHunting版参与讨论
相关主题
Divide Two Integers OJ和CCP150的做法关于除法的问题
Interview street上的一题求助计算乘法和除法,不用乘法和除法符号,怎么scale
Help...leetcode divide two integers两个整数除法的问题太刁钻了吧
面试题求解leetcode上的2个整数相除
求教EA一道面试题leecode上的divide two integers问题
贡献个面试题,目前狗狗都没找到.....两整数相除问题
Divide Two Integers关于Divide a integer
问一个facebook的电面题leetcode: Divide Two Integers 怎么做?
相关话题的讨论汇总
话题: unfriendly话题: numbers话题: divide话题: number话题: java