EASY DP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
不AC才说明问题。
program p14(input, output);
type
HugeInt = array [1..300] of longint;
var
W: boolean;
S: string;
k, Current, t, i, j: longint;
n, Cycle, Factor, CurrentFactor: HugeInt;
operator * (HugeFactor1, HugeFactor2: HugeInt) ResultFactor: HugeInt;
var
i, j: longint;
begin
fillchar(ResultFactor, sizeof(ResultFactor), 0);
for i := 1 to k do
begin
for j := 1 to k do
inc(ResultFactor[i + j - 1], HugeFactor1[i] * HugeFactor2[j]);
if ResultFactor[i] > 9 then
begin
inc(ResultFactor[i + 1], ResultFactor[i] div 10);
ResultFactor[i] := ResultFactor[i] mod 10
end
end
end;
operator * (HugeFactor: HugeInt; SmallFactor: longint) ResultFactor: HugeInt;
var
i: longint;
begin
fillchar(ResultFactor, sizeof(ResultFactor), 0);
for i := 1 to k do
begin
inc(ResultFactor[i], HugeFactor[i] * SmallFactor);
if ResultFactor[i] > 9 then
begin
inc(ResultFactor[i + 1], ResultFactor[i] div 10);
ResultFactor[i] := ResultFactor[i] mod 10
end
end
end;
operator = (C1, C2: HugeInt) ResultBool: boolean;
var
i: longint;
begin
for i := 1 to Current do
if C1[i] <> C2[i] then
begin
ResultBool := false;
exit
end;
ResultBool := true
end;
begin
fillchar(n, sizeof(n), 0);
fillchar(Cycle, sizeof(Cycle), 0);
readln(S);
t := pos( , S);
for i := t - 1 downto 1 do
n[t - i] := ord(S[i]) - ord(0);
k := 0;
for i := t + 1 to length(S) do
k := k * 10 + ord(S[i]) - ord(0);
Cycle[1] := 1;
Factor := n;
CurrentFactor := Factor;
for Current := 1 to k do
begin
i := 0;
while (CurrentFactor * n <> n) and (i <= 10) do
begin
inc(i);
CurrentFactor := CurrentFactor * Factor
end;
if i > 10 then
begin
writeln(-1);
halt
end;
Cycle := Cycle * (i + 1);
Factor := CurrentFactor
end;
W := false;
for i := 300 downto 1 do
if W then
write(Cycle[i])
else if Cycle[i] > 0 then
begin
write(Cycle[i]);
W := true
end;
writeln
end.
看不懂
operator * (HugeFactor1, HugeFactor2: HugeInt) ResultFactor: HugeInt是啥东东?