1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| #pragma warning(disable:4996)
#include<bits/stdc++.h> #define upf(a,b,c) for(ll a=b;a<=c;++a) #define drf(a,b,c) for(ll a=b;a>=c;--a) #define ll long long const int mod(1e9 + 7); const double esp(1e-6); const int maxn(1e5 + 5); using namespace std; ll T, n, k;
const int MAXN = 11000; ll prime[MAXN + 1]; void getPrime() { memset(prime, 0, sizeof(prime)); for (ll i = 2; i <= MAXN; i++) { if (!prime[i])prime[++prime[0]] = i; for (ll j = 1; j <= prime[0] && prime[j] * i <= MAXN; j++) { prime[prime[j] * i] = 1; if (i % prime[j] == 0)break; } } } int main() { #ifdef ACM_LOCAL freopen("./ACM.in", "r", stdin); freopen("./ACM.out", "w", stdout); #endif ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
memset(prime, 0, sizeof(prime)); getPrime(); cin >> T; while (T--) { cin >> n; ll num = 100; ll number; upf(i, 1, 1235) { number = 0; while (n % prime[i] == 0) { n /= prime[i]; number++; } if (number != 0) num = min(number, num); if (num == 1) break; } ll tmp2, tmp3, tmp4; tmp2 = pow(n, 0.5)+0.5; tmp3 = pow(n, 1.0 / 3)+0.5; tmp4 = pow(n, 0.25)+0.5; if (pow(tmp4, 4) == n && n != 1) { if (num > 4) num = 4; } else if (pow(tmp3, 3) == n && n != 1) { if (num > 3) num = 3; } else if (pow(tmp2, 2) == n && n != 1) { if (num > 2) num = 2; } else if(n!=1){ num = 1; } if (num == 100) num = 0; cout << num << '\n'; } }
|