ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1071. Nikifor 2

Why I got Output Limit? What does it mean?
Posted by Tang RZ 6 Jul 2004 10:16
My program:
var
  x,y,x1,y1,k:longint;
  a,b:array [1..10000] of integer;

procedure init;
begin
  read(x,y);
  x1:=x;
  y1:=y;
end;

procedure work;
var
  flag,flag1:boolean;
  k1,k2,k3,i:longint;
begin
  k:=1;
  repeat
    x1:=x;
    y1:=y;
    inc(k);
    if k>=x then writeln('No solution');
    k1:=0;
    k2:=0;
    repeat
      inc(k1);
      a[k1]:=x1 mod k;
      x1:=x1 div k;
    until x1=0;
    repeat
      inc(k2);
      b[k2]:=y1 mod k;
      y1:=y1 div k;
    until y1=0;
    k3:=1;
    for i:=1 to k2 do
      repeat
        flag1:=false;
        if b[i]=a[k3] then begin flag1:=true; b[i]:=-1;end;
        inc(k3);
      until (flag1)or(k3>=k1);
    flag:=true;
    for i:=1 to k2 do
      if b[i]<>-1 then flag:=false;
  until flag;
end;

procedure print;
begin
  writeln(k);
end;

begin
  init;
  work;
  print;
end.
How many times do you write 'No solution' if there is no solution?
Write

if k>=x then begin writeln('No solution'); halt; end;

instead

if k>=x then writeln('No solution');

and you'll get WA5 instead OLE3.