SHARE
TWEET

Untitled

lalalalalalalaalalla Sep 29th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <iomanip>
  5. #include <queue>
  6. #include <cmath>
  7. #include <algorithm>
  8. #include <tuple>
  9. #include <iomanip>
  10. #include <stdio.h>
  11. #include <numeric>
  12. #include <map>
  13. #include <bitset>
  14. #include <set>
  15. #include <stack>
  16. #include <queue>
  17.  
  18. /*
  19. #pragma GCC optimize("Ofast,no-stack-protector")
  20. #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
  21. #pragma GCC optimize("unroll-loops")
  22. #pragma GCC optimize("fast-math")
  23. #pragma GCC optimize("section-anchors")
  24. #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
  25. #pragma GCC optimize("vpt")
  26. #pragma GCC optimize("rename-registers")
  27. #pragma GCC optimize("move-loop-invariants")
  28. #pragma GCC optimize("unswitch-loops")
  29. #pragma GCC optimize("function-sections")
  30. #pragma GCC optimize("data-sections")
  31. #pragma GCC optimize("branch-target-load-optimize")
  32. #pragma GCC optimize("branch-target-load-optimize2")
  33. #pragma GCC optimize("btr-bb-exclusive")
  34. */
  35.  
  36. #define int long long
  37. #define ll long long
  38. #define ull unsigned long long
  39. #define all(a) a.begin(), a.end()
  40. #define pii pair<int, int>
  41. #define pb push_back
  42. #define ld long double
  43.  
  44.  
  45. using namespace std;
  46.  
  47. const int INF = 1e13;
  48. //const int mod = 2600000069;
  49. //const int p = 179;
  50.  
  51. const ull mod = 1000000007;
  52.  
  53. void solve() {
  54.    
  55. }
  56.  
  57. long long gcd(long long a, long long b) {
  58.     if (a==0) return b;
  59.     if (b==0) return a;
  60.     if (a>b) return gcd(a%b,b); else return gcd(b%a,a);
  61. }
  62.  
  63. bool check(int a) {
  64.     vector<bool> was(11, 0);
  65.     while (a != 0) {
  66.         if (was[a % 10]) return 0;
  67.         was[a % 10] = 1;
  68.         a /= 10;
  69.     }
  70.     return 1;
  71. }
  72.  
  73. ull powmod(ull a, ull b, ull mod) {
  74.     if (a == 1 or b == 0) {if (mod == 1) return 0; else return 1;}
  75.     if (b%2) {ull k = powmod(a,b/2,mod); return ((k*k)%mod*a)%mod;}
  76.     else {ull k = powmod(a,b/2,mod); return (k*k)%mod;}
  77. }
  78.  
  79. bool prime(ull p) {
  80.     if (p == 1) return 0;
  81.     for (ull i=2;i*i<=p;i++) {
  82.         if (p%i==0 && i<p) return false;
  83.     }
  84.     return true;
  85. }
  86.  
  87.  
  88. signed main() {
  89.     ios_base::sync_with_stdio(0);
  90.     cin.tie(0);
  91.     cout.tie(0);
  92.     ull n;
  93.     ull x;
  94.     cin >> x >> n;
  95. //    cout << x << " " << n << "\n";
  96.     set<ull> div;
  97.     ull q = x;
  98. //    cout << sqrt(x) << "\n";
  99.     if (prime(q)) {
  100.         div.insert(q);
  101.     } else {
  102.     for (ull i = 2; i*i <= q; i++) {
  103.         if (q % i == 0 && prime(i)) {
  104.             div.insert(i);
  105.         }
  106.     }
  107.     }
  108.  
  109. //    cout << "here\n";
  110. //    for (auto k : div) cout << k << " ";
  111. //    cout << "\n";
  112.     ull ans = 1;
  113.     ull w;
  114. //    cout << mod * mod << "\n";
  115. //    bool ok = 0;
  116.     for (auto k : div) {
  117.         w = n;
  118.         while (w/k != 0) {
  119. //            ok = 1;
  120.             ans *= powmod(k, w/k, mod);
  121. //            cout << w/(ull)k << "\n";
  122. //            cout << w << " " << k << "\n";
  123.             w /= (ull)k;
  124.             ans %= mod;
  125.         }
  126.     }
  127.     cout << ans;
  128. }
  129. /*
  130.  
  131. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top