/ Vijos / 讨论 / 循环 /

一只小智障求各位大神帮忙检查一下程序错误……连样例都没过,表示很方QAQ

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 条评论

  • 1

信息

ID
1032
难度
7
分类
高精度 点击显示
标签
递交数
4111
已通过
879
通过率
21%
被复制
35
上传者