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

Still WA!
Posted by Acid Pea 26 May 2003 04:50
program p1071;
var x,y,z,s,i:longint;
    out:boolean;
procedure check(p:longint);
var x1,y1,temp,i:longint;
    c:array[1..1000] of longint;
begin
     x1:=x;y1:=y;z:=0;
     fillchar(c,sizeof(c),0);
     repeat
           inc(z);
           c[z]:=x1 mod p;
           x1:=x1 div p;
     until x1=0;
     repeat
           temp:=y1 mod p;
           for i:=1 to z+1 do if c[i]=temp then
           begin
                c[i]:=-1;
                break;
           end;
           if i=z+1 then exit;
           y1:=y1 div p;
     until y1=0;
     out:=true;
end;
begin
     readln(x,y);z:=0;out:=false;
     for i:=2 to x do
         if x mod i=y mod i then
         begin
              check(i);
              if out then break;
         end;
     if out then writeln(i)
            else writeln('No solution');
     readln;
end.
Re: Don't "Chuan" me change your name!!!!!!!
Posted by Ural_??? 26 May 2003 16:57
> program p1071;
> var x,y,z,s,i:longint;
>     out:boolean;
> procedure check(p:longint);
> var x1,y1,temp,i:longint;
>     c:array[1..1000] of longint;
> begin
>      x1:=x;y1:=y;z:=0;
>      fillchar(c,sizeof(c),0);
>      repeat
>            inc(z);
>            c[z]:=x1 mod p;
>            x1:=x1 div p;
>      until x1=0;
>      repeat
>            temp:=y1 mod p;
>            for i:=1 to z+1 do if c[i]=temp then
>            begin
>                 c[i]:=-1;
>                 break;
>            end;
>            if i=z+1 then exit;
>            y1:=y1 div p;
>      until y1=0;
>      out:=true;
> end;
> begin
>      readln(x,y);z:=0;out:=false;
>      for i:=2 to x do
>          if x mod i=y mod i then
>          begin
>               check(i);
>               if out then break;
>          end;
>      if out then writeln(i)
>             else writeln('No solution');
>      readln;
> end.
Do u think Ural_intone is very "American Buffalo Shit"?(-)
Posted by Make me laugh 26 May 2003 19:03
Re:I think so.
Posted by Ural_xu zhanpeng 11 Jun 2003 19:37
>