|
|
вернуться в форумWhy WA on Test 6? program p1110; var r,n,m,x,y:longint; flag:boolean; function pow(x,y,n:longint):longint; var res:integer; begin res := 1; while (y>0) do begin if (y mod 2 = 1) then res := (res * x) mod n; y := y div 2; x := x * x; end; pow := res; end; begin readln(n,m,y); flag := False; for x:=1 to m-1 do begin r := pow(x,n,m); if r = y then begin if flag then write(' '); write(x); flag := True; end; end; if not flag then write('-1'); writeln; end. |
|
|