Redian新闻
>
700块以下,是Pentax的KX最好吗?
avatar
700块以下,是Pentax的KX最好吗?# PhotoGear - 摄影器材
w*x
1
做了无数recursion的题后花了两小时才整出gray code解, 大家鄙视我吧, 哈哈哈:
/*
The gray code is a binary numeral system where two successive values differ
in only one bit.
Given a non-negative integer n representing the total number of bits in the
code, print the sequence of gray code. A gray code sequence must begin with
0.
For example, given n = 2, return [0,1,3,2]. Its gray code sequence is:
00 - 0
01 - 1
11 - 3
10 - 2
*/
void _inner_sol(int& nCur, vector& vec, int nStopPos, int nPos)
{
if (nPos < 0)
{
vec.push_back(nCur);
return;
}
_inner_sol(nCur, vec, nStopPos, nPos-1);
if (nPos >= nStopPos)
return;
//flip nPos at nCur
nCur ^= (1 << nPos);
_inner_sol(nCur, vec, nStopPos, nPos-1);
}
vector grayCode(int n) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
vector vec;
if (0 == n)
vec.push_back(0);
else
{
int nCur = 0;
_inner_sol(nCur, vec, n, 31);
}
return vec;
}
avatar
c*z
2
请问从discover online saving往其他银行账户转钱,要交手续费么?谢谢!
avatar
I*e
3
PENTAX KX
12.4MP Digital SLR Camera with 18-55mm Lens
$649.99
avatar
p*2
4
我还没练过呢。自己鄙视自己一下。
avatar
l*a
5
no for transfer
avatar
x*c
6
你以后一定会买饼干头么?

【在 I********e 的大作中提到】
: PENTAX KX
: 12.4MP Digital SLR Camera with 18-55mm Lens
: $649.99

avatar
p*2
7
这个真要鄙视你了。
我大概做了10分钟。
public ArrayList grayCode(int n)
{
ArrayList al = new ArrayList();
al.add(0);
for (int i = 1; i <= n; i++)
{
int a = 1 << (i - 1);
for (int j = al.size() - 1; j >= 0; j--)
{
al.add(al.get(j) | a);
}
}
return al;
}
avatar
b*g
8
从对方银行pull免费

【在 c*z 的大作中提到】
: 请问从discover online saving往其他银行账户转钱,要交手续费么?谢谢!
avatar
k*n
9
sony a550/a500

【在 I********e 的大作中提到】
: PENTAX KX
: 12.4MP Digital SLR Camera with 18-55mm Lens
: $649.99

avatar
t*h
10
膜拜楼上的两位牛人,gray code是什么?
avatar
c*q
11
canon 500D
Nikon D90
avatar
p*2
12

你不是在梦游吧?

【在 t**********h 的大作中提到】
: 膜拜楼上的两位牛人,gray code是什么?
avatar
v*a
13
sony a550

【在 I********e 的大作中提到】
: PENTAX KX
: 12.4MP Digital SLR Camera with 18-55mm Lens
: $649.99

avatar
w*x
14
啊, 一直没有弄出gray code的本质, 二爷简洁的代码真是一语惊醒梦中人.
现在对二爷的敬仰犹如滔滔江水连绵不绝,犹如黄河泛滥一发不可收拾
avatar
I*e
15
哪里有DEAL?
没发现......

【在 k*****n 的大作中提到】
: sony a550/a500
avatar
p*2
16

靠。别来了。其实这个规律zhangchi大神已经总结过了。你还记得吗?

【在 w****x 的大作中提到】
: 啊, 一直没有弄出gray code的本质, 二爷简洁的代码真是一语惊醒梦中人.
: 现在对二爷的敬仰犹如滔滔江水连绵不绝,犹如黄河泛滥一发不可收拾

avatar
I*e
17
基本上,不太可能

【在 x****c 的大作中提到】
: 你以后一定会买饼干头么?
avatar
w*x
18
期末以后把板上漏下来的题再归纳一下写一遍, 完全不在状态啊~~
avatar
I*e
19
真的啊
新机+套头?
从哪里弄?

【在 v***a 的大作中提到】
: sony a550
:
avatar
p*2
20

我看你已经总结到300题了。很牛呀。我最近才开始总结。也就是100题这样子。我觉得
至少得总结到200题才行。

【在 w****x 的大作中提到】
: 期末以后把板上漏下来的题再归纳一下写一遍, 完全不在状态啊~~
avatar
v*a
21
ebay找HK卖家dzone
版三刚买了一台 很不错

【在 I********e 的大作中提到】
: 哪里有DEAL?
: 没发现......

avatar
w*x
22

我啥时候总结道300了, 你哪看的??

【在 p*****2 的大作中提到】
:
: 我看你已经总结到300题了。很牛呀。我最近才开始总结。也就是100题这样子。我觉得
: 至少得总结到200题才行。

avatar
x*c
23
那别入丐了

【在 I********e 的大作中提到】
: 基本上,不太可能
avatar
p*2
24

一亩三分地吧。

【在 w****x 的大作中提到】
:
: 我啥时候总结道300了, 你哪看的??

avatar
I*e
25
港行?
保修怎么处理

【在 v***a 的大作中提到】
: ebay找HK卖家dzone
: 版三刚买了一台 很不错

avatar
w*x
26

刚才又仔细看了一下, 这个规律太牛擦了, 由于太牛擦了, 所以就不研究了....
还是研究一下为什么递归做这么烂吧...

【在 p*****2 的大作中提到】
: 这个真要鄙视你了。
: 我大概做了10分钟。
: public ArrayList grayCode(int n)
: {
: ArrayList al = new ArrayList();
: al.add(0);
: for (int i = 1; i <= n; i++)
: {
: int a = 1 << (i - 1);
: for (int j = al.size() - 1; j >= 0; j--)

avatar
c*y
27
赌它1年不坏

【在 I********e 的大作中提到】
: 港行?
: 保修怎么处理

avatar
w*x
28

那个丢的都是废题, careercup网站和csdn上没意义的题, 根本没用,
那个好像是10个月前丢的

【在 p*****2 的大作中提到】
:
: 一亩三分地吧。

avatar
v*a
29
一年内用坏的可能性相当相当小
sony的质量可不是佳能

【在 I********e 的大作中提到】
: 港行?
: 保修怎么处理

avatar
r*e
30
如果只是为了生成Gray code, 最简单的方法是:
grayCode = binary ^ (binary>>1);
avatar
I*e
31
Seller info
dzone2 ( 30557) 99.6% Positive feedback
是这个吧,
$548.00
只是BODY啊
货是港行吗?

【在 v***a 的大作中提到】
: 一年内用坏的可能性相当相当小
: sony的质量可不是佳能

avatar
p*2
32

废题你还做了300道?你太牛X了。

【在 w****x 的大作中提到】
:
: 那个丢的都是废题, careercup网站和csdn上没意义的题, 根本没用,
: 那个好像是10个月前丢的

avatar
y*e
33
我觉得500以下,KX最好的可能性更大一点。

【在 I********e 的大作中提到】
: PENTAX KX
: 12.4MP Digital SLR Camera with 18-55mm Lens
: $649.99

avatar
t*h
34
求一亩三分地的地址

一亩三分地吧。
★ Sent from iPhone App: iReader Mitbbs Lite 7.56

【在 p*****2 的大作中提到】
:
: 废题你还做了300道?你太牛X了。

avatar
n*P
35
有deal的啊,kx我是460买的

【在 I********e 的大作中提到】
: PENTAX KX
: 12.4MP Digital SLR Camera with 18-55mm Lens
: $649.99

avatar
C*U
36
你们两太像我本科的几个同学了。。。

differ
the
with

【在 w****x 的大作中提到】
: 做了无数recursion的题后花了两小时才整出gray code解, 大家鄙视我吧, 哈哈哈:
: /*
: The gray code is a binary numeral system where two successive values differ
: in only one bit.
: Given a non-negative integer n representing the total number of bits in the
: code, print the sequence of gray code. A gray code sequence must begin with
: 0.
: For example, given n = 2, return [0,1,3,2]. Its gray code sequence is:
: 00 - 0
: 01 - 1

avatar
v*a
37
这个机器是入门机里最好的
配套头有点可惜
建议配小菜头1680DT

【在 I********e 的大作中提到】
: Seller info
: dzone2 ( 30557) 99.6% Positive feedback
: 是这个吧,
: $548.00
: 只是BODY啊
: 货是港行吗?

avatar
f*0
38

膜拜。。。。

【在 r*****e 的大作中提到】
: 如果只是为了生成Gray code, 最简单的方法是:
: grayCode = binary ^ (binary>>1);

avatar
L*k
39
a500用了吗?

【在 k*****n 的大作中提到】
: sony a550/a500
avatar
C*U
40
Wiki上的结论不错
http://en.wikipedia.org/wiki/Gray_code

做了无数recursion的题后花了两小时才整出gray code解, 大家鄙视我吧, 哈哈哈:/*
The gray code is a binary numeral syst........
★ Sent from iPhone App: iReader Mitbbs 7.56 - iPad Lite

【在 w****x 的大作中提到】
: 做了无数recursion的题后花了两小时才整出gray code解, 大家鄙视我吧, 哈哈哈:
: /*
: The gray code is a binary numeral system where two successive values differ
: in only one bit.
: Given a non-negative integer n representing the total number of bits in the
: code, print the sequence of gray code. A gray code sequence must begin with
: 0.
: For example, given n = 2, return [0,1,3,2]. Its gray code sequence is:
: 00 - 0
: 01 - 1

avatar
p*e
41
Olympus E620
avatar
J*r
42
这个不对吧

【在 r*****e 的大作中提到】
: 如果只是为了生成Gray code, 最简单的方法是:
: grayCode = binary ^ (binary>>1);

avatar
v*a
43
+1
这个还是双头套 才600块

【在 p********e 的大作中提到】
: Olympus E620
avatar
r*e
44
for what input binary number does not it work?

【在 J*********r 的大作中提到】
: 这个不对吧
avatar
p*n
45
canon质量比sony还差?

【在 v***a 的大作中提到】
: 一年内用坏的可能性相当相当小
: sony的质量可不是佳能

avatar
x*9
46
提到的大神是买买提上的么?求总结。

【在 p*****2 的大作中提到】
:
: 废题你还做了300道?你太牛X了。

avatar
c*y
47
要不怎么是奸C
不过要说S的质量好,低端机上我也没有体会到。。。,不过镜头的做工确实比奸C好

【在 p****n 的大作中提到】
: canon质量比sony还差?
avatar
p*2
48

是呀。你去考考古。最近刚拿到F和G的双offer。

【在 x******9 的大作中提到】
: 提到的大神是买买提上的么?求总结。
avatar
R*a
49
S低端机也就A100做工比较好,所以它停产了

【在 c********y 的大作中提到】
: 要不怎么是奸C
: 不过要说S的质量好,低端机上我也没有体会到。。。,不过镜头的做工确实比奸C好

avatar
l*a
50
写了个递归版本的。
vector code(int n){
if(n == 0){
vector codes;
codes.push_back(0);
return codes;
}
vector oneless = code(n - 1);
int len = oneless.size();
for(int i = len - 1; i >= 0; i--){
oneless.push_back(oneless[i]);
}
for(int i = 0; i < len; i++){
int ele = oneless[i+len];
ele |= 1 << (n - 1);
oneless[i+len] = ele;
}
return oneless;
}
avatar
v*a
51
至少不会捏上去就嘎吱嘎吱响

【在 c********y 的大作中提到】
: 要不怎么是奸C
: 不过要说S的质量好,低端机上我也没有体会到。。。,不过镜头的做工确实比奸C好

avatar
I*C
52
This is the shortest code I have ever seen for gray code.
-------------------------
vector grayCode(int n) {
vector result;

int size = 1<
for (int i = 0; i < size; ++i)
result.push_back((i >> 1) ^ i);

return result;
}
-------------------------
But have not idea why this works.
Anyone can help answer why this works?
Thanks!

【在 f****0 的大作中提到】
:
: 膜拜。。。。

avatar
c*y
53
机身的做工,我是最不关心的了,
两三年以后,都是淘汰的东西。。。

【在 v***a 的大作中提到】
: 至少不会捏上去就嘎吱嘎吱响
avatar
f*y
54


【在 I***C 的大作中提到】
: This is the shortest code I have ever seen for gray code.
: -------------------------
: vector grayCode(int n) {
: vector result;
:
: int size = 1<:
: for (int i = 0; i < size; ++i)
: result.push_back((i >> 1) ^ i);
:

avatar
a*e
55
老中直接frys买这种东西那真成那美克星人了

【在 I********e 的大作中提到】
: PENTAX KX
: 12.4MP Digital SLR Camera with 18-55mm Lens
: $649.99

avatar
C*U
56
所以做太多也会把脑子做乱了
有时候更应该冷静一下整理一下code
有点想高考啊!哈哈

differ
the
with

【在 w****x 的大作中提到】
: 做了无数recursion的题后花了两小时才整出gray code解, 大家鄙视我吧, 哈哈哈:
: /*
: The gray code is a binary numeral system where two successive values differ
: in only one bit.
: Given a non-negative integer n representing the total number of bits in the
: code, print the sequence of gray code. A gray code sequence must begin with
: 0.
: For example, given n = 2, return [0,1,3,2]. Its gray code sequence is:
: 00 - 0
: 01 - 1

avatar
k*n
57


【在 L*****k 的大作中提到】
: a500用了吗?
avatar
e*o
58
it is easy to see that size = 1 << n.
but
can anyone explain why the ith number is ( i>>1 )^i ?

【在 I***C 的大作中提到】
: This is the shortest code I have ever seen for gray code.
: -------------------------
: vector grayCode(int n) {
: vector result;
:
: int size = 1<:
: for (int i = 0; i < size; ++i)
: result.push_back((i >> 1) ^ i);
:

avatar
v*a
59
屯久了小心发霉啊

【在 k*****n 的大作中提到】
: 没
avatar
l*a
60
1)why use Integer and int simultaneously?
2)most of the JAVA developers won't write like this
ArrayList al = new ArrayList();

【在 p*****2 的大作中提到】
: 这个真要鄙视你了。
: 我大概做了10分钟。
: public ArrayList grayCode(int n)
: {
: ArrayList al = new ArrayList();
: al.add(0);
: for (int i = 1; i <= n; i++)
: {
: int a = 1 << (i - 1);
: for (int j = al.size() - 1; j >= 0; j--)

avatar
k*n
61
A200卖不掉啊

【在 v***a 的大作中提到】
: 屯久了小心发霉啊
avatar
g*e
62
那怎么写
List al = new ArrayList();
这样?

【在 l*****a 的大作中提到】
: 1)why use Integer and int simultaneously?
: 2)most of the JAVA developers won't write like this
: ArrayList al = new ArrayList();

avatar
L*k
63
让你爸到国内去处理掉算了。

【在 k*****n 的大作中提到】
: A200卖不掉啊
avatar
g*e
64
我觉得这个题当电面不错,收藏之

【在 l*****a 的大作中提到】
: 1)why use Integer and int simultaneously?
: 2)most of the JAVA developers won't write like this
: ArrayList al = new ArrayList();

avatar
b*e
66
Ha, this is more like a math problem ...
Look at the table below:
bit_5 bit_4 bit_3 bit_2 bit_1
0 0 0 0 0
0 0 0 0 1
0 0 0 1
0 0 0 1
0 0 1
0 0 1
0 0 1
0 0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
For the missing entries, if you just repeat the bit pattern for lower bit
columns, then row N has the binary representation of N. However, if you
repeat the bit pattern in reverse (i.e. flipped), then switch back, and so
on ... then you get the Gray code for N.
Since you switch every 2^k rows, you just need to check the previous column
to see if the bits are to be reversed.
Thus, if ( N's bit k+1) == 0, bit k of Gray code = bit k of N;
else (i.e. N's k+1'th bit is 1), bit k of Gray code = flip (bit k of N)
That translates to (N>>1) ^ N.
avatar
r*e
67
it is correct because the equation is derived from digital logic which is
Gray code's origin.
Use K-Map on the truth table when the variables are not too many, otherwise
not easy to use
K-map even though it still works.
FYI, grayToBinary(unsigned int num)
unsigned int numBits = 8*sizeof(num); //here 8 means each byte has 8 bits
unsigned int shift;
for (shift=1; shiftnum ^= num>>shift;
return num;

【在 I***C 的大作中提到】
: This is the shortest code I have ever seen for gray code.
: -------------------------
: vector grayCode(int n) {
: vector result;
:
: int size = 1<:
: for (int i = 0; i < size; ++i)
: result.push_back((i >> 1) ^ i);
:

avatar
f*4
68
f(i)=(i>>1)^i, 只要比较一下f(i)和f(i-1)的关系就能看出来了
另外生成只相差一位不同的序列也不唯一,
比如已有长度为i-1的序列,在向长度i扩展时只需在i-1序列的后考虑添加1,接着再走一
遍i-1序列,是对称的.归纳法

【在 e******o 的大作中提到】
: it is easy to see that size = 1 << n.
: but
: can anyone explain why the ith number is ( i>>1 )^i ?

avatar
S*1
69
public class Solution {
public ArrayList grayCode(int n) {
ArrayList result =new ArrayList();
if(n<=0)
return result;

result.add(0);
result.add(1);

for(int i=2; i<=n; i++){
for(int j=result.size()-1;j>=0;j--){
result.add(result.get(j)+(1<}
}

return result;
}
}
avatar
A*g
70
很弱的问一下,这个点解?
第一个数000
000^(000>>1) = 000^000 = 000?

【在 r*****e 的大作中提到】
: 如果只是为了生成Gray code, 最简单的方法是:
: grayCode = binary ^ (binary>>1);

avatar
h*n
71
强烈的对称性。。。

differ
the
with

【在 w****x 的大作中提到】
: 做了无数recursion的题后花了两小时才整出gray code解, 大家鄙视我吧, 哈哈哈:
: /*
: The gray code is a binary numeral system where two successive values differ
: in only one bit.
: Given a non-negative integer n representing the total number of bits in the
: code, print the sequence of gray code. A gray code sequence must begin with
: 0.
: For example, given n = 2, return [0,1,3,2]. Its gray code sequence is:
: 00 - 0
: 01 - 1

avatar
A*g
72
看了两小时没看懂,二爷能讲讲这是啥子算法吗?
循环套循环里面array size 还变 ...

【在 p*****2 的大作中提到】
: 这个真要鄙视你了。
: 我大概做了10分钟。
: public ArrayList grayCode(int n)
: {
: ArrayList al = new ArrayList();
: al.add(0);
: for (int i = 1; i <= n; i++)
: {
: int a = 1 << (i - 1);
: for (int j = al.size() - 1; j >= 0; j--)

avatar
A*g
73
Trace 一下二爷的code
i=1, [000] | [001]
i=2, [000, 001] | [010]
i=3, [000, 001, 011, 010] | [100]
[000, 001, 011, 010, 110, 111, 101, 100]
我所知道的gray code,
1. 变最右一位
2. 变最右边开始第一个1的左边
repeat 1,2 直到没得变...
实在无法和这么精妙的算法联系起来啊, 求解释...
不然实在记不住啊
avatar
a*x
74
研究了一下,确实code写得很简洁明了,下面wiki得解释也很帮助理解。
http://en.wikipedia.org/wiki/Gray_code#Constructing_an_n-bit_Gr

【在 p*****2 的大作中提到】
: 这个真要鄙视你了。
: 我大概做了10分钟。
: public ArrayList grayCode(int n)
: {
: ArrayList al = new ArrayList();
: al.add(0);
: for (int i = 1; i <= n; i++)
: {
: int a = 1 << (i - 1);
: for (int j = al.size() - 1; j >= 0; j--)

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。