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 WA?!
Posted by Drizzt 19 Jul 2003 15:05
Could anyone tell me why I always got WA?
Thank you.
Here is my program :

program N2 (input, output);
  var lX, lY, lK : longint;
      x, y : array [1.. 1000] of longint;
  function solve (lT : longint) : boolean;
    var lX1, lY1, lU, lV, lMax : longint;
    begin
      lU := 1000;
      lV := 1000;
      lX1 := lX;
      lY1 := lY;
      repeat
        x [lU] := lX1 mod lT;
        lX1 := lX1 div lT;
        lU := lU - 1;
      until lX1 = 0;
      repeat
        y [lV] := lY1 mod lT;
        lY1 := lY1 div lT;
        lV := lV - 1;
      until lY1 = 0;
      lU := lU + 1;
      lV := lV + 1;
      lMax := 1001 - lV;
      for lX1 := lU to 1000 do
        if y [lV] = x [lX1] then
          begin
            lMax := lMax - 1;
            lV := lV + 1;
          end;
      if lMax = 0 then solve := true
                  else solve := false;
    end;
  begin
    readln (lX, lY);
    lK := 2;
    repeat
      if solve (lK) = true then
        begin
          writeln (lK);
          halt;
        end;
      lK := lK + 1;
    until lK > lX;
    writeln ('No solution');
  end.