SlepoiKrot

Untitled

Jan 9th, 2018
95
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program G;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils;
  7. var
  8.   n, a, i, i1, j: integer;
  9.   m: int64;
  10. begin
  11.   readln (n);
  12.   for i := 1 to n do begin
  13.     read (a);
  14.     m := 1;
  15.     j := 0;
  16.     if (a = 1) or (a = 2) or (a = 3) then begin
  17.       writeln (a, ' ', 1);
  18.       continue;
  19.     end;  
  20.     for i1 := 2 to trunc(sqrt(a)) do begin
  21.       while (m < a) do begin
  22.         m := m * i1;
  23.         inc (j);
  24.       end;
  25.       if (m = a) then begin
  26.         writeln (i1, ' ', j);
  27.         break;
  28.       end
  29.       else if (i1 = trunc(sqrt(a))) then begin
  30.         writeln (a, ' ', 1);
  31.         break;
  32.       end  
  33.       else begin
  34.         m := 1;
  35.         j := 0;
  36.         continue;
  37.       end;
  38.     end;
  39.   end;
  40.   readln;
  41.   readln;
  42. end.
RAW Paste Data