www.aa.com/AAdvantage30 Thank you for being a Citi® / AAdvantage® and/or CitiBusiness® ; / AAdvantage® credit cardmember. To celebrate the 30th anniversary of the AAdvantage® program, the AAdvantage® program would like to thank you with 1,000 AAdvantage® bonus miles.1, 2 Eligible Citi® / AAdvantage® and CitiBusiness® / AAdvantage 174; credit cardmembers who register a valid AAdvantage® number below will receive 1,000 AAdvantage® bonus miles.1, 2 The AAdvantage® number you enter must belong to the primary credit cardmember.
我在那个连接里怎么没看到说要送1000 我的是显示这个 May 10SPECIAL ANNIVERSARY OFFERS UP TO 60K MILES First time Citi® / AAdvantage® credit cardmembers can earn 30,000 AAdvantage bonus miles after making $1,000 in purchases within 4 months of becoming a cardmember. Plus, earn an additional 30,000 AAdvantage bonus miles after making $10,000 in purchases during your first 12 months as a credit cardmember!* (offer ends May 27, 2011)
【在 l**u 的大作中提到】 : 用 : int i = 100123311 : int counter; : 可以 : while(i>0){ : if(i%10==1) counter ++; : i=i/10; : }
m*s
11 楼
+1 这个1000 in first 4 months是什么意思啊
000
【在 f******r 的大作中提到】 : 我在那个连接里怎么没看到说要送1000 : 我的是显示这个 : May 10SPECIAL ANNIVERSARY OFFERS UP TO 60K MILES : First time Citi® / AAdvantage® credit cardmembers can earn 30,000 : AAdvantage bonus miles after making $1,000 in purchases within 4 months of : becoming a cardmember. Plus, earn an additional 30,000 AAdvantage bonus : miles after making $10,000 in purchases during your first 12 months as a : credit cardmember!* (offer ends May 27, 2011)
l*u
12 楼
啊。我看错料。你的那个方法应该也可以。效率可能会比较高吧。
【在 m****n 的大作中提到】 : int numberofones(unsigned int number) : { : if(number == 0) : return 0; : number = ((0xaaaaaaaa&number)>>1) + (0x55555555&number); : number = ((0xcccccccc&number)>>2) + (0x33333333&number); : number = ((0xf0f0f0f0&number)>>4) + (0x0f0f0f0f&number); : number = ((0xff00ff00&number)>>8) + (0x00ff00ff&number); : number = (number>>16) + (0x0000ffff&number); : return number;
r*e
13 楼
有两个选项。 第二个“already a citi card memeber?..."
000
【在 f******r 的大作中提到】 : 我在那个连接里怎么没看到说要送1000 : 我的是显示这个 : May 10SPECIAL ANNIVERSARY OFFERS UP TO 60K MILES : First time Citi® / AAdvantage® credit cardmembers can earn 30,000 : AAdvantage bonus miles after making $1,000 in purchases within 4 months of : becoming a cardmember. Plus, earn an additional 30,000 AAdvantage bonus : miles after making $10,000 in purchases during your first 12 months as a : credit cardmember!* (offer ends May 27, 2011)
l*c
14 楼
1. bit op 2. loop 3. x&(x-1)
l*8
15 楼
为嘛我信用卡号都没输,就直接说注册好了……
l*u
16 楼
不过说实话,我没太看懂。 我看的这些a呀f呀就晕掉了 可以用bit运算做的话,不知道对不对。 int counter =0; int i = 1212321; i = Math.abs(i); while (i > 0) { i = i >>> 1; if ((i & 0X1) == 1) { counter++; } } System.out.println(counter);
【在 m****n 的大作中提到】 : int numberofones(unsigned int number) : { : if(number == 0) : return 0; : number = ((0xaaaaaaaa&number)>>1) + (0x55555555&number); : number = ((0xcccccccc&number)>>2) + (0x33333333&number); : number = ((0xf0f0f0f0&number)>>4) + (0x0f0f0f0f&number); : number = ((0xff00ff00&number)>>8) + (0x00ff00ff&number); : number = (number>>16) + (0x0000ffff&number); : return number;
r*e
17 楼
3x
174; of
【在 c*****x 的大作中提到】 : www.aa.com/AAdvantage30 : Thank you for being a Citi® / AAdvantage® and/or CitiBusiness® : ; / AAdvantage® credit cardmember. To celebrate the 30th anniversary of : the AAdvantage® program, the AAdvantage® program would like to : thank you with 1,000 AAdvantage® bonus miles.1, 2 : Eligible Citi® / AAdvantage® and CitiBusiness® / AAdvantage : 174; credit cardmembers who register a valid AAdvantage® number below : will receive 1,000 AAdvantage® bonus miles.1, 2 : The AAdvantage® number you enter must belong to the primary credit : cardmember.
m*n
18 楼
我那个意思就是: 假设 X = 4*a + 2*b + 1*c 我们要求的是:Y = a +b+c; 把 X >> 1, 得到的是 2*a + b,加上之前的X 就得到了 a+b 用掩码保护下 a+b ,继续吧X 右移相加,移动了 32位之后就得到最高的那个了 我说不好。。。你google下吧
【在 l**u 的大作中提到】 : 不过说实话,我没太看懂。 : 我看的这些a呀f呀就晕掉了 : 可以用bit运算做的话,不知道对不对。 : int counter =0; : int i = 1212321; : i = Math.abs(i); : while (i > 0) { : i = i >>> 1; : if ((i & 0X1) == 1) { : counter++;
b*s
19 楼
thanks
s*t
20 楼
int a = 12345; int count = 0; for( int i = a; i != 0; i = i>>1 ){ count += i & 1; } printf("%d", count);
【在 s*********t 的大作中提到】 : int a = 12345; : int count = 0; : for( int i = a; i != 0; i = i>>1 ){ : count += i & 1; : } : printf("%d", count);
s*z
23 楼
我有两长,我以为可以搞两次,sigh....
174; of
【在 c*****x 的大作中提到】 : www.aa.com/AAdvantage30 : Thank you for being a Citi® / AAdvantage® and/or CitiBusiness® : ; / AAdvantage® credit cardmember. To celebrate the 30th anniversary of : the AAdvantage® program, the AAdvantage® program would like to : thank you with 1,000 AAdvantage® bonus miles.1, 2 : Eligible Citi® / AAdvantage® and CitiBusiness® / AAdvantage : 174; credit cardmembers who register a valid AAdvantage® number below : will receive 1,000 AAdvantage® bonus miles.1, 2 : The AAdvantage® number you enter must belong to the primary credit : cardmember.
s*t
24 楼
楼主这个careercup上的题目,我刚好看过,见笑了
【在 w******1 的大作中提到】 : 这个方法不错啊。
C*a
25 楼
thanks!
174; of
【在 c*****x 的大作中提到】 : www.aa.com/AAdvantage30 : Thank you for being a Citi® / AAdvantage® and/or CitiBusiness® : ; / AAdvantage® credit cardmember. To celebrate the 30th anniversary of : the AAdvantage® program, the AAdvantage® program would like to : thank you with 1,000 AAdvantage® bonus miles.1, 2 : Eligible Citi® / AAdvantage® and CitiBusiness® / AAdvantage : 174; credit cardmembers who register a valid AAdvantage® number below : will receive 1,000 AAdvantage® bonus miles.1, 2 : The AAdvantage® number you enter must belong to the primary credit : cardmember.
s*a
26 楼
这个best
【在 l******c 的大作中提到】 : 1. bit op : 2. loop : 3. x&(x-1)
N*S
27 楼
我怎么看不见提交的地方?
l*o
28 楼
这个方法有意思。
int numberofones(unsigned int number) { if(number == 0) return 0; number = ((0xaaaaaaaa&number)>>1) + (0x55555555&number); number = ((0xcccccccc&number)>>2) + (0x03333333&number); number = ((0xf0f0f0f0&number)>>4) + (0x0f0f0f0f&number); number = ((0xff00ff00&number)>>8) + (0x00ff00ff&number); number = (number>>16) + (0x0000ffff&number); return number; }
【在 m****n 的大作中提到】 : int numberofones(unsigned int number) : { : if(number == 0) : return 0; : number = ((0xaaaaaaaa&number)>>1) + (0x55555555&number); : number = ((0xcccccccc&number)>>2) + (0x33333333&number); : number = ((0xf0f0f0f0&number)>>4) + (0x0f0f0f0f&number); : number = ((0xff00ff00&number)>>8) + (0x00ff00ff&number); : number = (number>>16) + (0x0000ffff&number); : return number;
c*g
29 楼
me too.
000
【在 f******r 的大作中提到】 : 我在那个连接里怎么没看到说要送1000 : 我的是显示这个 : May 10SPECIAL ANNIVERSARY OFFERS UP TO 60K MILES : First time Citi® / AAdvantage® credit cardmembers can earn 30,000 : AAdvantage bonus miles after making $1,000 in purchases within 4 months of : becoming a cardmember. Plus, earn an additional 30,000 AAdvantage bonus : miles after making $10,000 in purchases during your first 12 months as a : credit cardmember!* (offer ends May 27, 2011)
x*y
30 楼
Actually, it's just a process of storing the number of bit 1 of every 2^n bits in every 2^n bits, n=1,2,...5.... The in-place bit operations makes it seem complicated...
【在 l******o 的大作中提到】 : 这个方法有意思。 : : int numberofones(unsigned int number) : { : if(number == 0) : return 0; : number = ((0xaaaaaaaa&number)>>1) + (0x55555555&number); : number = ((0xcccccccc&number)>>2) + (0x03333333&number); : number = ((0xf0f0f0f0&number)>>4) + (0x0f0f0f0f&number); : number = ((0xff00ff00&number)>>8) + (0x00ff00ff&number);
h*n
31 楼
me three,是不是显示这个就没戏了.
【在 c****g 的大作中提到】 : me too. : : 000
f*4
32 楼
int bitCounter(int number){ int counter = 0; int n = sizeof(int) * 8; int mask = 1 << (n - 1); for(int i = 1; i <= n; ++i) { if((mask & number) != 0) ++counter; number <<= 1; } return counter; } 只能做<>会有1多出来的
f*n
33 楼
Thank you. It works!
; / AAdvantage® credit cardmember. To celebrate the 30th anniversary of the AAdvantage® program, the AAdvantage® program would like to reg; credit cardmembers who register a valid AAdvantage® number below will receive 1,000 AAdvantage® bonus miles.1, 2 cardmember. NUMBER>
【在 c*****x 的大作中提到】 : www.aa.com/AAdvantage30 : Thank you for being a Citi® / AAdvantage® and/or CitiBusiness® : ; / AAdvantage® credit cardmember. To celebrate the 30th anniversary of : the AAdvantage® program, the AAdvantage® program would like to : thank you with 1,000 AAdvantage® bonus miles.1, 2 : Eligible Citi® / AAdvantage® and CitiBusiness® / AAdvantage : 174; credit cardmembers who register a valid AAdvantage® number below : will receive 1,000 AAdvantage® bonus miles.1, 2 : The AAdvantage® number you enter must belong to the primary credit : cardmember.
Is it expired? I got following message after click "REGISTER NOW": "Oops! You've reached your maximum number of entries allowed. Please see rules for more details."
; / AAdvantage® credit cardmember. To celebrate the 30th anniversary of the AAdvantage® program, the AAdvantage® program would like to reg; credit cardmembers who register a valid AAdvantage® number below will receive 1,000 AAdvantage® bonus miles.1, 2 cardmember. NUMBER>
【在 c*****x 的大作中提到】 : www.aa.com/AAdvantage30 : Thank you for being a Citi® / AAdvantage® and/or CitiBusiness® : ; / AAdvantage® credit cardmember. To celebrate the 30th anniversary of : the AAdvantage® program, the AAdvantage® program would like to : thank you with 1,000 AAdvantage® bonus miles.1, 2 : Eligible Citi® / AAdvantage® and CitiBusiness® / AAdvantage : 174; credit cardmembers who register a valid AAdvantage® number below : will receive 1,000 AAdvantage® bonus miles.1, 2 : The AAdvantage® number you enter must belong to the primary credit : cardmember.
【在 y***n 的大作中提到】 : Is it expired? I got following message after click "REGISTER NOW": : "Oops! You've reached your maximum number of entries allowed. Please see : rules for more details." : : ; / AAdvantage® credit cardmember. To celebrate the 30th anniversary of : the AAdvantage® program, the AAdvantage® program would like to : reg; credit cardmembers who register a valid AAdvantage® number below : will receive 1,000 AAdvantage® bonus miles.1, 2 : cardmember. : NUMBER>
l*o
38 楼
int numberofones(unsigned int number) { if(number == 0) return 0; number = ((0xaaaaaaaa&number)>>1) + (0x55555555&number); number = ((0xcccccccc&number)>>2) + (0x03333333&number); ~~~~~~~ 0x33333333吧 number = ((0xf0f0f0f0&number)>>4) + (0x0f0f0f0f&number); number = ((0xff00ff00&number)>>8) + (0x00ff00ff&number); number = (number>>16) + (0x00
【在 m****n 的大作中提到】 : int numberofones(unsigned int number) : { : if(number == 0) : return 0; : number = ((0xaaaaaaaa&number)>>1) + (0x55555555&number); : number = ((0xcccccccc&number)>>2) + (0x33333333&number); : number = ((0xf0f0f0f0&number)>>4) + (0x0f0f0f0f&number); : number = ((0xff00ff00&number)>>8) + (0x00ff00ff&number); : number = (number>>16) + (0x0000ffff&number); : return number;
b*k
39 楼
thx but dead here
174;; / AAdvantage® credit cardmember. To celebrate the 30th anniversary of the AAdvantage® program, the AAdvantage® program would like to ® credit cardmembers who register a valid AAdvantage® number below will receive 1,000 AAdvantage® bonus miles.1, 2 cardmember. NUMBER>
【在 c*****x 的大作中提到】 : www.aa.com/AAdvantage30 : Thank you for being a Citi® / AAdvantage® and/or CitiBusiness® : ; / AAdvantage® credit cardmember. To celebrate the 30th anniversary of : the AAdvantage® program, the AAdvantage® program would like to : thank you with 1,000 AAdvantage® bonus miles.1, 2 : Eligible Citi® / AAdvantage® and CitiBusiness® / AAdvantage : 174; credit cardmembers who register a valid AAdvantage® number below : will receive 1,000 AAdvantage® bonus miles.1, 2 : The AAdvantage® number you enter must belong to the primary credit : cardmember.
For the first one,in the 2nd step it should be (0x33333333&number) instead of (0x03333333&number); In the link, int NumberOfSetBits(int i) { i = i - ((i >> 1) & 0x55555555); i = (i & 0x33333333) + ((i >> 2) & 0x33333333); return ((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; } It's basically the same as the first one. The first two steps are the same as number = ((0xaaaaaaaa&number)>>1) + (0x55555555&number); number = ((0xcccccccc&number)>>2) + (0x33333333&number); and in the last s
【在 x***y 的大作中提到】 : For the first one,in the 2nd step it should be (0x33333333&number) instead : of (0x03333333&number); : In the link, : int NumberOfSetBits(int i) : { : i = i - ((i >> 1) & 0x55555555); : i = (i & 0x33333333) + ((i >> 2) & 0x33333333); : return ((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; : } : It's basically the same as the first one. The first two steps are the same
b*v
46 楼
unsigned int t = 0; for(unsigned int i=0; i<32; i++) { t += (n>>i)&1; } cout << "The number " << n << " has " << t << " one's" << endl;