Advertisement
ivnikkk

Untitled

Jun 21st, 2022
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #define debug(tl) cerr<<#tl<<' '<<tl<<'\n';
  3. #include "bits/stdc++.h"
  4. using namespace std;
  5. #define all(d) d.begin(), d.end()
  6. typedef long long ll;
  7. typedef pair<ll, ll> pll;
  8. typedef long double ld;
  9. signed main() {
  10. #ifdef _DEBUG
  11.     freopen("input.txt", "r", stdin);
  12.     freopen("output.txt", "w", stdout);
  13. #endif
  14.     ios_base::sync_with_stdio(false);
  15.     cin.tie(nullptr);
  16.     cout.tie(nullptr);
  17.     constexpr int N = 1e6 + 2;
  18.     bitset<N> p;
  19.     p[0] = p[1] = 1;
  20.     for (ll i = 2; i < N; i++) {
  21.         if (!p[i] && i * 1ll * i < N) {
  22.             for (ll j = i * i; j < N; j += i) {
  23.                 p[j] = 1;
  24.             }
  25.         }
  26.     }
  27.     vector<ll> prime(1,2);
  28.     for (ll i = 1; i < N; i+=2) {
  29.         if (!p[i]) {
  30.             prime.push_back(i);
  31.         }
  32.     }
  33.     int t;
  34.     cin >> t;
  35.     while (t--) {
  36.         ll n;
  37.         cin >> n;
  38.         ll ans = 1;
  39.         for (ll i = 0; i < (ll)prime.size(); i++) {
  40.             ll x = prime[i];
  41.             ll cnt = 0;
  42.             while (n % x == 0) {
  43.                 n /= x;
  44.                 cnt++;
  45.             }
  46.             ans = max(cnt, ans);
  47.             if (x * x * x > n)break;
  48.         }
  49.         if (n != 1) {
  50.             ll sq = sqrt(n);
  51.             if (sq * sq == n) {
  52.                 ans = max(ans, 2ll);
  53.             }
  54.         }
  55.         cout << ans << '\n';
  56.     }
  57. }
  58.  
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement