由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - I have one program to find primer between 2 and 1023 with bitset, but I don't understand one line
相关主题
saleforce 店面,攒人品吧。问一个经典题目
一道算法题目Bitmap是怎么回事啊?
求解答:Find multiple missing numbers一道微软题
求教一道老题苦等了三个星期,终于等到offer来啦!(完)
3rd Amazon phone interview (1hr)问个简单的金融公司的coding面试题
让人沮丧的Goog电话面试数组里面找数个出现了奇数次的整数,怎么找?
求助:bitmap的问题问一道算法题
问个bit struct的面试题 急amazon问题求教
相关话题的讨论汇总
话题: find话题: bitset话题: 1023话题: primer话题: int
进入JobHunting版参与讨论
1 (共1页)
c******f
发帖数: 2144
1
const int size = 1024;
bitset sieve;
sieve.flip();
int finalBit = sqrt(sieve.size())+1;
for (int i=2;i if (sieve.test(i))
for(int j = 2*i;j sieve.reset(j);
Question:
In this program we set all 1024 bits as all "1"(which means 1111...111)
here we will find 2 and set all numbers like 4, 6, 8, ...,10 to 0
then find 3 and set all numbers like 6,9,12...to 0
then find 4 and set all numbers like 8,12,...to 0
until the loop is finished, we will find
s*********t
发帖数: 1663
2
32的平方是1024
如果比32大的数能整除某个小于1024的数那么商肯定比32小,已经check过了

【在 c******f 的大作中提到】
: const int size = 1024;
: bitset sieve;
: sieve.flip();
: int finalBit = sqrt(sieve.size())+1;
: for (int i=2;i: if (sieve.test(i))
: for(int j = 2*i;j: sieve.reset(j);
: Question:
: In this program we set all 1024 bits as all "1"(which means 1111...111)

c******f
发帖数: 2144
3
prime not primer
1 (共1页)
进入JobHunting版参与讨论
相关主题
amazon问题求教3rd Amazon phone interview (1hr)
请教一道Amazon面世题让人沮丧的Goog电话面试
Amazon电话面试第一轮求助:bitmap的问题
算法题:两列找共同元素有O(n)的算法吗?问个bit struct的面试题 急
saleforce 店面,攒人品吧。问一个经典题目
一道算法题目Bitmap是怎么回事啊?
求解答:Find multiple missing numbers一道微软题
求教一道老题苦等了三个星期,终于等到offer来啦!(完)
相关话题的讨论汇总
话题: find话题: bitset话题: 1023话题: primer话题: int