import
static
program.Binary.*;
//
数独类
public
class
CrossWord {
public
static
void
main(String[]
args
) {
String
str
=
"000000000000000000000000000000000000000000000000000000000000000000000000000000000"
;
long
s
= System.
currentTimeMillis
();
load
(
str
);
System.
out
.println(System.
currentTimeMillis
() -
s
);
System.
gc
();
}
private
static
int
[]
row
=
new
int
[9],
col
=
new
int
[9];
private
static
int
[][]
square
=
new
int
[3][3],
cell
=
new
int
[9][9];
private
static
int
[]
x
=
new
int
[81],
y
=
new
int
[81];
private
static
final
int
[]
trailZero
=
new
int
[257];
private
static
int
n
= 0;
private
static
final
int
max
= 0x1FF;
static
{
for
(
int
i
= 1;
i
i
++)
//
储存
1
到
256
每一个数的二进制最后有多少个
0
trailZero
[
i
] =
lastZeroBitCount
(
i
) + 1;
}
public
static
void
load(String
input
){
int
[][]
_cell
=
new
int
[9][9];
for
(
int
i
= 0;
i
<
input
.length();
i
++){
char
c
=
input
.charAt(
i
);
_cell
[
i
/ 9][
i
% 9] = (
c
& Integer.
MAX_VALUE
) - 48;
}
load
(
_cell
);
}
public
static
void
load(
int
[][]
input
){
java.util.Arrays.
fill
(
x
, -1);
java.util.Arrays.
fill
(
y
, -1);
int
t
[] =
new
int
[81],
i
,
j
;
for
(
i
= 0;
i
i
++){
for
(
j
= 0;
j
j
++){
System.
out
.print(
input
[
i
][
j
] +
" "
);
cell
[
i
][
j
] =
input
[
i
][
j
];
if
(
input
[
i
][
j
] == 0){
//
记录空格
x
[
n
] =
i
;
y
[
n
++] =
j
;
continue
;
}
//
非空方格
int
tmp
= 1 <<
input
[
i
][
j
] >> 1;
//
这一格的二进制表示数
row
[
i
] |=
tmp
;
//
储存可能值的数组添加已经填好的方格
col
[
j
] |=
tmp
;
square
[
i
/ 3][
j
/ 3] |=
tmp
;
}
System.
out
.println();
}
for
(
i
= 0;
i
<
n
;
i
++)
//
得到与这一个空格有联系的行、列和九宫格的非空数字的个数