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

Maigo Akisame (maigoakisame@yahoo.com.cn) Why WA on test#8? [2] // Problem 1110. Power 1 Jul 2004 04:51
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.
Dmitry 'Diman_YES' Kovalioff Check your mail - I've sent you explanation of your mistake (-) // Problem 1110. Power 1 Jul 2004 10:53
MAZURENKO BOGDAN Re: Why WA on test#8? // Problem 1110. Power 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.