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 1110. Power

Why WA on test#8?
program ural1110;
var
  n,m,x,r,i:integer;
  y:byte;
  first:boolean;
begin
  readln(n,m,y);
  first:=true;
  for x:=0 to m-1 do begin
    r:=1;
    for i:=1 to n do
      r:=(r*x) mod m;
    if r=y then begin
      if first then first:=false else write(' ');
      write(x);
    end;
  end;
  if first then writeln(-1) else writeln;
end.
Check your mail - I've sent you explanation of your mistake (-)
Posted by Dmitry 'Diman_YES' Kovalioff 1 Jul 2004 10:53
Re: Why WA on test#8?
Posted by MAZURENKO BOGDAN 8 Oct 2006 18:34
program ural1110;
var
n,m,x,r,i:longint;
y:longint;
first:boolean;
begin
readln(n,m,y);
first:=true;
for x:=0 to m-1 do begin
r:=1;
for i:=1 to n do
r:=(r*x) mod m;
if r=y then begin
if first then first:=false else write(' ');
write(x);
end;
end;
if first then writeln(-1) else writeln;
end.