Guest User

Untitled

a guest
Jul 16th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. uses Math;
  2.  
  3. var a,n,t1,t2,i,t3,t4,x1,x2,max,ans,t5 : longint;
  4.  
  5. procedure no;
  6. begin
  7. writeln(0);
  8. halt(0);
  9. end;
  10.  
  11. procedure calc(i : longint);
  12. begin
  13. { if t2 mod i = 0 then
  14. if t1 mod i <> 0 then
  15. no else
  16. begin}
  17. t3 := 0;
  18. t4 := 0 ;
  19. if t1 mod i <> 0 then no;
  20. while t2 mod i = 0 do begin t2 := t2 div i; inc(t3);end;
  21. while t1 mod i = 0 do begin t1 := t1 div i; inc(t4);end;
  22. if ceil(t3/t4) > max then
  23. begin
  24. max := ceil(t3/t4);
  25. x1 := t3;
  26. x2 := t4;
  27. t5 := i;
  28. end;
  29. // end;
  30. end;
  31.  
  32. begin
  33. assign(input,'h.in');
  34. assign(output,'h.out');
  35. reset(input);
  36. rewrite(output);
  37. readln(a,n);
  38. if a mod n = 0 then begin writeln(1); HALT(0); END;
  39. t1 := a;
  40. t2 := n;
  41. {for i := 2 to n div 2 do
  42. calc(i);}
  43. i := 2;
  44. while i <= (n div 2) do
  45. begin if t2 mod i = 0 then calc(i); inc(i);end;
  46. if t2 <> 1 then calc(n);
  47. ans := 1;
  48. while x1 > x2 do
  49. begin
  50. inc(ans);
  51. x1 := trunc(LogN(t5,x1));
  52. end;
  53. writeln(ans);
  54. end.
Add Comment
Please, Sign In to add comment