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

Whats wrong with this?
Posted by abdkanan 7 Feb 2006 01:25
var
 n,m,y:longint;
 x:longint;
 i,j,s:longint;
 b:boolean;
 mas:array[1..999] of longint;

begin
 read(n,m,y);
 x:=1;
 b:=false;
 for i:=0 to m-1 do begin
  for j:=1 to n do begin
   x:=x*i;
  end;
  if (x mod m) = y then begin
   s:=s+1;
   mas[s]:=i;
   b:=true;
  end;
  x:=1;
 end;
 if b then for i:=1 to s do write(mas[i],' ') else write(-1);
 readln;readln;
end.

Edited by author 07.02.2006 01:26
test for you
Posted by +FAMAS+ 7 Feb 2006 01:51
998 998 1
ANS 1 997

996 4 1
ANS 1 3