Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #define debug(tl) cerr<<#tl<<' '<<tl<<'\n';
- #include "bits/stdc++.h"
- using namespace std;
- #define all(d) d.begin(), d.end()
- typedef long long ll;
- typedef pair<ll, ll> pll;
- typedef long double ld;
- signed main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- constexpr int N = 1e6 + 2;
- bitset<N> p;
- p[0] = p[1] = 1;
- for (ll i = 2; i < N; i++) {
- if (!p[i] && i * 1ll * i < N) {
- for (ll j = i * i; j < N; j += i) {
- p[j] = 1;
- }
- }
- }
- vector<ll> prime(1,2);
- for (ll i = 1; i < N; i+=2) {
- if (!p[i]) {
- prime.push_back(i);
- }
- }
- int t;
- cin >> t;
- while (t--) {
- ll n;
- cin >> n;
- ll ans = 1;
- for (ll i = 0; i < (ll)prime.size(); i++) {
- ll x = prime[i];
- ll cnt = 0;
- while (n % x == 0) {
- n /= x;
- cnt++;
- }
- ans = max(cnt, ans);
- if (x * x * x > n)break;
- }
- if (n != 1) {
- ll sq = sqrt(n);
- if (sq * sq == n) {
- ans = max(ans, 2ll);
- }
- }
- cout << ans << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement