Advertisement
tungSfer

132_exp

Jun 12th, 2022
1,000
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define ll long long
  4. #define pb push_back
  5. #define pii pair<int, int>
  6. #define pll pair<ll, ll>
  7. #define el endl
  8. #define umi unordered_map<int, int>
  9. #define umll unordered_map<ll, ll>
  10. #define all(vect) vect.begin(), vect.end()
  11. #define reset(A, x) memset(A, x, sizeof(A))
  12. #define approx(n) fixed << setprecision(n)
  13.  
  14. using namespace std;
  15.  
  16. const int mod = 1e9 + 7;
  17.  
  18. int log_a_to_base_b(int a, int b)
  19. {
  20.   return int(log2(a) / log2(b));
  21. }
  22.  
  23. void solve() {
  24.   int n;
  25.   cin >> n;
  26.   int maxx = 0;
  27.   for(int i = 2; i < n; i++) {
  28.     int te = log_a_to_base_b(n, i);
  29.     int p = pow(i, te);
  30.     if(p > maxx && p <= n) {
  31.       maxx = p;
  32.     }
  33.   }
  34.   cout << maxx << el;
  35. }
  36.  
  37. int main()
  38. {
  39.   ios_base::sync_with_stdio(false);
  40.   cin.tie(NULL);
  41.  
  42.   int t = 1;
  43.   // cin >> t;
  44.   // cin.ignore();
  45.   while (t--) {
  46.     solve();
  47.   }
  48.   return 0;
  49. }
  50.  
  51. /*
  52.  
  53. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement