#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
bool pr[100100];
vector<int> p;
map<basic_string<int>, vector<double> > ma;
vector<double> solve(basic_string<int> &a);
vector<double> rec(basic_string<int> &a, vector<int> &cnt, int ×, int pos) {
if (pos == (int)a.size()) {
bool ok = false;
REP(i, cnt.size()) if (cnt[i] != 0) {
ok = true;
break;
}
if (!ok) return vector<double>();
ok = false;
REP(i, cnt.size()) if (cnt[i] != a[i]) {
ok = true;
break;
}
if (!ok) return vector<double>();
basic_string<int> b, c;
REP(i, a.size()) {
if (cnt[i] != 0) b += cnt[i];
if (a[i] != cnt[i]) c += a[i] - cnt[i];
}
sort(b.begin(), b.end());
sort(c.begin(), c.end());
vector<double> v1 = solve(b);
vector<double> v2 = solve(c);
if (v1.size() < v2.size()) swap(v1, v2);
v2.resize(v1.size());
for (int i = 1; i < (int)v1.size(); ++i) {
v1[i] += v1[i - 1];
v2[i] += v2[i - 1];
}
REP(i, v1.size()) v1[i] *= v2[i];
for (int i = (int)v1.size() - 1; i > 0; --i) {
v1[i] -= v1[i - 1];
}
++times;
return v1;
}
vector<double> ret;
REP(i, a[pos] + 1) {
cnt[pos] = i;
vector<double> cur = rec(a, cnt, times, pos + 1);
if (ret.size() < cur.size()) ret.resize(cur.size());
REP(i, cur.size()) ret[i] += cur[i];
}
return ret;
}
vector<double> solve(basic_string<int> &a) {
auto it = ma.find(a);
if (it != ma.end()) {
return it->second;
}
if ((int)a.size() == 1 && a[0] == 1) {
return ma[a] = vector<double>(1, 1.0);
}
vector<int> cnt(a.size());
int times = 0;
vector<double> res = rec(a, cnt, times, 0);
double di = 1.0 / times;
REP(i, res.size()) res[i] *= di;
res.resize(res.size() + 1);
for (int i = (int)res.size() - 1; i > 0; --i) res[i] = res[i - 1];
res[0] = 0;
return ma[a] = res;
}
int main() {
//freopen("input.txt", "r", stdin);
REP(i, 100100) pr[i] = true;
pr[0] = pr[1] = false;
REP(i, 1000) if (pr[i]) {
for (int j = i * i; j < 100100; j += i) {
pr[j] = false;
}
}
REP(i, 100100) if (pr[i]) {
p.pb(i);
}
int tt;
scanf("%d", &tt);
REP(test, tt) {
LL x;
scanf("%lld", &x);
basic_string<int> a;
for (int i = 0; (LL)p[i] * p[i] <= x; ++i) if (x % p[i] == 0) {
x /= p[i];
int cnt = 1;
while (x % p[i] == 0) {
x /= p[i];
++cnt;
}
a.pb(cnt);
}
if (x > 1) a.pb(1);
sort(a.begin(), a.end());
vector<double> res = solve(a);
double ans = 0;
REP(i, res.size()) ans += i * res[i];
printf("%.9f\n", ans);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBSRVAoaSwgbikgZm9yIChpbnQgaSA9IDA7IGkgPCAoaW50KShuKTsgKytpKQp0eXBlZGVmIGxvbmcgbG9uZyBMTDsKdHlwZWRlZiBwYWlyPGludCwgaW50PiBQSUk7Cgpib29sIHByWzEwMDEwMF07CnZlY3RvcjxpbnQ+IHA7Cm1hcDxiYXNpY19zdHJpbmc8aW50PiwgdmVjdG9yPGRvdWJsZT4gPiBtYTsKCnZlY3Rvcjxkb3VibGU+IHNvbHZlKGJhc2ljX3N0cmluZzxpbnQ+ICZhKTsKCnZlY3Rvcjxkb3VibGU+IHJlYyhiYXNpY19zdHJpbmc8aW50PiAmYSwgdmVjdG9yPGludD4gJmNudCwgaW50ICZ0aW1lcywgaW50IHBvcykgewogICAgaWYgKHBvcyA9PSAoaW50KWEuc2l6ZSgpKSB7CiAgICAgICAgYm9vbCBvayA9IGZhbHNlOwogICAgICAgIFJFUChpLCBjbnQuc2l6ZSgpKSBpZiAoY250W2ldICE9IDApIHsKICAgICAgICAgICAgb2sgPSB0cnVlOwogICAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgaWYgKCFvaykgcmV0dXJuIHZlY3Rvcjxkb3VibGU+KCk7CiAgICAgICAgb2sgPSBmYWxzZTsKICAgICAgICBSRVAoaSwgY250LnNpemUoKSkgaWYgKGNudFtpXSAhPSBhW2ldKSB7CiAgICAgICAgICAgIG9rID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmICghb2spIHJldHVybiB2ZWN0b3I8ZG91YmxlPigpOwogICAgICAgIGJhc2ljX3N0cmluZzxpbnQ+IGIsIGM7CiAgICAgICAgUkVQKGksIGEuc2l6ZSgpKSB7CiAgICAgICAgICAgIGlmIChjbnRbaV0gIT0gMCkgYiArPSBjbnRbaV07CiAgICAgICAgICAgIGlmIChhW2ldICE9IGNudFtpXSkgYyArPSBhW2ldIC0gY250W2ldOwogICAgICAgIH0KICAgICAgICBzb3J0KGIuYmVnaW4oKSwgYi5lbmQoKSk7CiAgICAgICAgc29ydChjLmJlZ2luKCksIGMuZW5kKCkpOwogICAgICAgIHZlY3Rvcjxkb3VibGU+IHYxID0gc29sdmUoYik7CiAgICAgICAgdmVjdG9yPGRvdWJsZT4gdjIgPSBzb2x2ZShjKTsKICAgICAgICBpZiAodjEuc2l6ZSgpIDwgdjIuc2l6ZSgpKSBzd2FwKHYxLCB2Mik7CiAgICAgICAgdjIucmVzaXplKHYxLnNpemUoKSk7CiAgICAgICAgZm9yIChpbnQgaSA9IDE7IGkgPCAoaW50KXYxLnNpemUoKTsgKytpKSB7CiAgICAgICAgICAgIHYxW2ldICs9IHYxW2kgLSAxXTsKICAgICAgICAgICAgdjJbaV0gKz0gdjJbaSAtIDFdOwogICAgICAgIH0KICAgICAgICBSRVAoaSwgdjEuc2l6ZSgpKSB2MVtpXSAqPSB2MltpXTsKICAgICAgICBmb3IgKGludCBpID0gKGludCl2MS5zaXplKCkgLSAxOyBpID4gMDsgLS1pKSB7CiAgICAgICAgICAgIHYxW2ldIC09IHYxW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XJuIG1hW2FdID0gcmVzOwp9CgppbnQgbWFpbigpIHsKICAgIC8vZnJlb3BlbigiaW5wdXQudHh0IiwgInIiLCBzdGRpbik7CiAgICBSRVAoaSwgMTAwMTAwKSBwcltpXSA9IHRydWU7CiAgICBwclswXSA9IHByWzFdID0gZmFsc2U7CiAgICBSRVAoaSwgMTAwMCkgaWYgKHByW2ldKSB7CiAgICAgICAgZm9yIChpbnQgaiA9IGkgKiBpOyBqIDwgMTAwMTAwOyBqICs9IGkpIHsKICAgICAgICAgICAgcHJbal0gPSBmYWxzZTsKICAgICAgICB9CiAgICB9CiAgICBSRVAoaSwgMTAwMTAwKSBpZiAocHJbaV0pIHsKICAgICAgICBwLnBiKGkpOwogICAgfQogICAgaW50IHR0OwogICAgc2NhbmYoIiVkIiwgJnR0KTsKICAgIFJFUCh0ZXN0LCB0dCkgewogICAgICAgIExMIHg7CiAgICAgICAgc2NhbmYoIiVsbGQiLCAmeCk7CiAgICAgICAgYmFzaWNfc3RyaW5nPGludD4gYTsKICAgICAgICBmb3IgKGludCBpID0gMDsgKExMKXBbaV0gKiBwW2ldIDw9IHg7ICsraSkgaWYgKHggJSBwW2ldID09IDApIHsKICAgICAgICAgICAgeCAvPSBwW2ldOwogICAgICAgICAgICBpbnQgY250ID0gMTsKICAgICAgICAgICAgd2hpbGUgKHggJSBwW2ldID09IDApIHsKICAgICAgICAgICAgICAgIHggLz0gcFtpXTsKICAgICAgICAgICAgICAgICsrY250OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGEucGIoY250KTsKICAgICAgICB9CiAgICAgICAgaWYgKHggPiAxKSBhLnBiKDEpOwogICAgICAgIHNvcnQoYS5iZWdpbigpLCBhLmVuZCgpKTsKICAgICAgICB2ZWN0b3I8ZG91YmxlPiByZXMgPSBzb2x2ZShhKTsKICAgICAgICBkb3VibGUgYW5zID0gMDsKICAgICAgICBSRVAoaSwgcmVzLnNpemUoKSkgYW5zICs9IGkgKiByZXNbaV07CiAgICAgICAgcHJpbnRmKCIlLjlmXG4iLCBhbnMpOwogICAgfQogICAgcmV0dXJuIDA7Cn0=