这种哈希方法很不错 int get_id(int x,int y,int z) { if(M[x][y][z])return M[x][y][z]; else return M[x][y][z]=tot++; }