fork download
  1. #include <iostream>
  2. using std::cin, std::cout;
  3. typedef long long ll;
  4. ll ans = 1, modulo = 1e9 + 7;
  5. void binary_pow(ll a, ll b)
  6. {
  7. ll tmp = a % modulo;
  8. while (b > 0)
  9. {
  10. if (b & 1)
  11. ans = (ans * tmp) % modulo;
  12. tmp = (tmp * tmp) % modulo;
  13. b >>= 1;
  14. }
  15. }
  16. int main()
  17. {
  18. std::ios::sync_with_stdio(false);
  19. cin.tie(nullptr);
  20. cout.tie(nullptr);
  21. ll n, i, j, tmp;
  22. cin >> n;
  23. bool free[n+1];
  24. for (i = 2; i <= n; ++i)
  25. if (!free[i])
  26. {
  27. tmp = n;
  28. j = 0;
  29. while ((tmp /= i) > 0)
  30. j += tmp;
  31. binary_pow(i, j - (ll) (j & 1));
  32. for (j = i; j <= n / i; ++j)
  33. free[i*j] = true;
  34. }
  35. cout << ans;
  36. }
Success #stdin #stdout 0s 5296KB
stdin
6
stdout
1