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

HELP PLEASE!!! WA#6
Posted by BlackShark 10 Jan 2009 00:41
var n,m,y,i:integer; x:int64; found:boolean;

function pow(x,a:integer):int64;
var i:integer; res:int64;
begin
res:=1;
for i:=1 to a do res:=res*x;
pow:=res;
end;

begin
found:=false;
readln(n,m,y);
for i:=0 to m-1 do begin
x:=pow(i,n) mod m;
if x=y then begin
found:=true;
write(i,' ');
end; end;
if not Found then writeln('-1');
end.