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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
| #include<bits/stdc++.h> #include<iostream> #include<cmath> #include<cstring> #include<algorithm> #include<cstdio> #include<stdlib.h> #include<time.h> #pragma warning(disable:4996) #define times 20 using namespace std; #define ll long long map<ll, ll> mp;
ll total; ll factor[110];
ll qmul(ll a, ll b, ll M) { a %= M; b %= M; ll ans = 0; while (b) { if (b & 1) { ans = (ans + a) % M; } a = (a <<= 1) % M; b >>= 1; } return ans % M; } ll qpow(ll a, ll b, ll int M) { ll ans = 1; ll k = a; while (b) { if (b & 1)ans = qmul(ans, k, M) % M; k = qmul(k, k, M) % M; b >>= 1; } return ans % M; }
bool witness(ll a, ll n, ll x, ll sum) { ll judge = qpow(a, x, n); if (judge == n - 1 || judge == 1)return 1; while (sum--) { judge = qmul(judge, judge, n); if (judge == n - 1)return 1; } return 0; }
bool miller(ll n) { if (n < 2)return 0; if (n == 2)return 1; if ((n & 1) == 0)return 0; ll x = n - 1; ll sum = 0; while (x % 2 == 0) { x >>= 1; sum++; } for (ll i = 1; i <= times; i++) { ll a = rand() % (n - 1) + 1; if (!witness(a, n, x, sum))return 0; } return 1; }
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll pollard(ll n, ll c) { ll x, y, d, i = 1, k = 2; x = rand() % n; y = x; while (1) { i++; x = (qmul(x, x, n) + c) % n; d = gcd(y - x, n); if (d < 0)d = -d; if (d > 1 && d < n)return d; if (y == x)return n; if (i == k) { y = x; k <<= 1; } } }
void find(ll n) { if (miller(n)) { factor[++total] = n; mp[n]++; return; } ll p = n; while (p >= n) p = pollard(p, rand() % (n - 1) + 1); find(n / p); find(p); }
int main() { int t; scanf("%d", &t); while (t--) { total = 0; ll n; scanf("%lld", &n); if (n == 1) { puts("no"); continue; } mp.clear(); find(n); int flag = 0; for (auto& tem : mp) { if (tem.second >= 2) { flag = 1; break; } } printf("%s\n", (flag == 1 ? "yes" : "no")); } }
|