Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/158.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何对大小为N的二维数组进行哈希?_C++_Hash - Fatal编程技术网

C++ 如何对大小为N的二维数组进行哈希?

C++ 如何对大小为N的二维数组进行哈希?,c++,hash,C++,Hash,如何对大小高达15*15的二维数组进行哈希。哈希函数必须唯一标识每个排列。例如,对于4*4矩阵 散列=0 hash = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { hash *= 13; hash += board[i][j]; if (hash > 10000003) hash %= 10000003; }

如何对大小高达15*15的二维数组进行哈希。哈希函数必须唯一标识每个排列。例如,对于4*4矩阵 散列=0

hash = 0;
for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
        hash *= 13;
        hash += board[i][j];
        if (hash > 10000003)
            hash %= 10000003;
    }
}
hash=0;
对于(int i=0;i<4;i++){
对于(int j=0;j<4;j++){
散列*=13;
哈希+=板[i][j];
如果(哈希值>10000003)
哈希%=10000003;
}
}

将4参数化有什么问题?根据,不可能为矩阵的每一种可能排列获得唯一的哈希值。(除非可能的排列比不同散列值的#少。)