Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Func {
  4. public static void main(String[]args)
  5. {
  6. Scanner scan=new Scanner(System.in);
  7. int T=scan.nextInt();
  8. for(int i=0;i<T;i++)
  9. {
  10. long N=scan.nextLong();
  11. boolean is=false;
  12. for(long j=1;j<=N;j++)
  13. {
  14. if(Math.pow(j, divisors(j))==N)
  15. {
  16. System.out.println(j);
  17. is=true;
  18. break;
  19. }
  20.  
  21.  
  22. }
  23. if(is==false) System.out.println(-1);
  24. }
  25. }
  26. public static long divisors(long n)
  27. {
  28.  
  29. long count=0;
  30. for(long i=2;i<=n/2;i++)
  31. {
  32. if(n%i==0)
  33. {
  34. count++;
  35.  
  36. }
  37. }
  38. return count+2;
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement