fork download
  1. using System;
  2.  
  3. class Program
  4. {
  5. const long MOD = 1000000007;
  6.  
  7. static int CountDivisors(long n)
  8. {
  9. int count = 0;
  10. for (long i = 1; i * i <= n; i++)
  11. {
  12. if (n % i == 0)
  13. {
  14. if (i == n / i)
  15. count++;
  16. else
  17. count += 2;
  18. }
  19. }
  20. return count;
  21. }
  22.  
  23. static long Power(long x, long y, long mod)
  24. {
  25. long result = 1;
  26. x = x % mod;
  27. while (y > 0)
  28. {
  29. if (y % 2 == 1)
  30. result = (result * x) % mod;
  31. x = (x * x) % mod;
  32. y /= 2;
  33. }
  34. return result;
  35. }
  36.  
  37. static long ProductOfDivisors(long n)
  38. {
  39. int d = CountDivisors(n);
  40. long sqrtN = (long)Math.Sqrt(n);
  41. if (d % 2 == 0)
  42. return Power(n, d / 2, MOD);
  43. else
  44. return (Power(n, d / 2, MOD) * sqrtN) % MOD;
  45. }
  46.  
  47. static void Main(string[] args)
  48. {
  49. int t = int.Parse(Console.ReadLine());
  50. for (int i = 0; i < t; i++)
  51. {
  52. long n = long.Parse(Console.ReadLine());
  53. Console.WriteLine(ProductOfDivisors(n));
  54. }
  55. }
  56. }
Success #stdin #stdout 0.06s 28116KB
stdin
2
1
2
stdout
1
2