- 循环
- 2016-10-03 15:26:11 @
program ex12;
var a,b:array[1..101] of integer;
r:array[1..201] of longint;
k,i,code,sum:integer;
s:string;
bool,t:boolean;
procedure cheng;
var
j:integer;
begin
for i:=1 to k do
for j:=1 to k do
begin
r[i+j-1]:=a[i]*b[j]+r[i+j-1];
while (r[i-j-1] div 10<>0) do
begin
r[i+j]:=r[i+j]+(r[i-j-1] div 10);
r[i-j-1]:=r[i-j-1] mod 10;
end;
end;
for i:=1 to k do
begin
a[i]:=a[i]+r[i];
while (a[i] div 10<>0) do
begin
r[i+1]:=r[i+1]+1;
a[i]:=a[i] mod 10;
end;
end;
end;
begin
read(s);
sum:=0;
k:=pos(s,' ');
for i:=1 to k do
begin
val(s[k-i],a[i],code);
r[i]:=0;
a[i]:=b[i];
end;
bool:=false;
while not(bool) do
begin
cheng;
for i:=1 to k do
if b[i]=a[i] then t:=true
else begin
t:=false;
break;
end;
if t=false then sum:=sum+1
else begin
bool:=true;
sum:=sum+1;
end;
if sum>300 then break;
end;
if bool then write(sum)
else write('-1');
end.
2 条评论
-
guoqianli LV 8 @ 2016-10-05 10:08:20
帮你看看
-
2016-10-05 10:08:03@
这是啥题?
- 1