📄 pku_1282.pas
字号:
Program pku_1282;
Const
Infile = 'Pku_1282.in';
limittime = 1000000000;
su : Array[1..6] of Integer = (2, 3, 5, 7, 11, 13);
Type
Arr1 = Array[1..200, 1..200] of Integer;
Arr2 = Array[1..200] of Integer;
Var
hou, clo: Byte;
a: Arr1;
p: Arr2;
ran, cir, i, j: Integer;
time: Longint;
f, fp: Boolean;
fz, fcir: Set of 1..200;
Function judge(x1, x2: Longint): Boolean;
Var
i1: Integer;
lx1, lx2: Integer;
ran1, ran2: Longint;
Begin
ran1 := x1;
ran2 := x2;
lx1 := 0;
lx2 := 0;
While ran1 > 0 do Begin
ran1 := ran1 div 10;
inc(lx1);
End;
While ran2 > 0 do Begin
ran2 := ran2 div 10;
inc(lx2);
End;
If lx2 + lx1 > 8 then
judge := false
Else
judge := true;
End;
Procedure Work(Var time: Longint; x: Integer);
Var
i1: Integer;
Begin
fp := true;
For i1 := 6 downto 1 do
While (x > su[i1]) and (x mod su[i1] = 0) do
If time mod su[i1] <> 0 then Begin
If judge(time, su[i1]) then
time := time * su[i1]
Else Begin
fp := false;
Break;
End;
x := x div su[i1];
End Else
x := x div su[i1];
If x <> 0 then
If judge(time, x) then
time := time * x
Else
fp := false;
End;
Begin
Assign(Input, Infile);
Reset(Input);
Readln(hou, clo);
For i := 1 to hou do Begin
For j := 1 to clo do Read(a[i, j]);
Readln;
End;
Close(Input);
f := true;
For i := 1 to clo do Begin
fz :=[];
For j := 1 to hou do
If (not (a[j, i] in fz)) and (a[j, i] <= hou) then
fz := fz + [a[j, i]]
Else
f := false;
End;
fz := [];
cir := 0;
If f = false then Begin
Write('No one knows.');
Halt;
End;
For i := 1 to hou do
If not (i in fz) then Begin
Inc(cir);
ran := i;
While not (ran in fz) do Begin
fz := fz + [ran];
Inc(p[cir]);
For j := 1 to clo do
ran := a[ran, j];
End;
End Else
Continue;
time := 1;
For i := 1 to cir do Begin
Work(time, p[i]);
If (time > limittime) or (not fp) then Begin
f := false;
Break;
End;
End;
fp := judge(time, clo);
If fp then
time := time * clo;
If (not fp) or (not f) or (time > limittime) then
Write('No one knows.')
Else
Write(time);
End.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -