2014-10-12 32 views

回答

3

在这种情况下,<<是左移位运算符。 1 << 18表示采用1的二进制表示并将其左移18位。这是2 (2表示电源18或262144)。所以,你必须对一个非常大的二维数组:

pair <int, int> approach[262144][17]; 
2

<<是位左移运算符。

所以1 << 18是一个整数常量值为2 。

1

它只是意味着2^18,2至18

代码缺少一些解释的权力,只有真正的好信息是

// SGU 502 -- Digits Permutation 

阿其对数字的排列,所以

pair <int, int> approach[1 << 18][17] 

可能被用来存储排列,除非排列上有一些限制,排列的数量应该是N! (希望是N! < =(1 < <18))。

但是这个定义并没有说明任何有关的信息,让我们看看我们是否可以使它更清楚(希望是正确的)。

const int maxLength = 17; 
const int maxPermutation = 1 << (maxLength+1); 
pair <int, int> approach[maxPermutation ][maxLength] 
static_assert(factorial(maxLength) <= maxPermutation, "approach might not be able to hold all permutations");