由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 看一道面试题
相关主题
贡献一下:本版上搜集的 Google 面试题 (转载)一FG家常见题 (转载)
问一道面试题一道面试题
Check if the sum of two integers in an integer array eqauls to the given number 讨论几个面试题
面试题 -算法?一道bit operator面试题
java有没有用户自定义长度integer类型?面试题求解 (转载)
[合集] 这个问题怎么解效率最高A weird segmentation fault!
structure to integer一个哈希表问题
a careercup questioncopy constructor问题。
相关话题的讨论汇总
话题: given话题: bits话题: bit话题: between话题: give
进入Programming版参与讨论
1 (共1页)
l*******r
发帖数: 511
1
【 以下文字转载自 JobHunting 讨论区 】
发信人: littlemar (小火星), 信区: JobHunting
标 题: 看一道面试题
发信站: BBS 未名空间站 (Mon Sep 28 20:36:19 2009, 美东)
given a 32 bit number N and 2 numbers(A & B) that determine 2 different bit
pos
itions of N how do you make all the bits between A and B equal to another
given
integer k.
given (A,B is in the range [0 to 31] and
k<=2^(B-A+1) ( so that k fits between B-A+1 bits). Give an O(1) solution for
th
is
e.g if N=9 ( 1001) ,A=0 ,B=2,K=5(101 then the result should be 1101 (1.e 13)
这个题是什
q***q
发帖数: 3356
2
可以做乘除法么?

bit

【在 l*******r 的大作中提到】
: 【 以下文字转载自 JobHunting 讨论区 】
: 发信人: littlemar (小火星), 信区: JobHunting
: 标 题: 看一道面试题
: 发信站: BBS 未名空间站 (Mon Sep 28 20:36:19 2009, 美东)
: given a 32 bit number N and 2 numbers(A & B) that determine 2 different bit
: pos
: itions of N how do you make all the bits between A and B equal to another
: given
: integer k.
: given (A,B is in the range [0 to 31] and

z**k
发帖数: 629
3
是问"这道题是什么意思?"还是问"这道题该怎么解?"
g*******y
发帖数: 1930
4
bitwise operator:
say A=1;B=3;
a = ~0;
a<<(B-A); // a= 111...1100
a = ~a; // a= 000...00011;
a< N = N & ~a; // N &1111..11001; clear bitA~bitB in N;
N = N | (k<
1 (共1页)
进入Programming版参与讨论
相关主题
copy constructor问题。java有没有用户自定义长度integer类型?
which is faster, table look up or bitwise operator?[合集] 这个问题怎么解效率最高
问个关于~的小问题(C++)structure to integer
两道M软件大公司的最新面世算法题 (转载)a careercup question
贡献一下:本版上搜集的 Google 面试题 (转载)一FG家常见题 (转载)
问一道面试题一道面试题
Check if the sum of two integers in an integer array eqauls to the given number 讨论几个面试题
面试题 -算法?一道bit operator面试题
相关话题的讨论汇总
话题: given话题: bits话题: bit话题: between话题: give