[Explanations] P5589 pig Paige playing games (expected)
Similar to this question , the establishment of a dag view of the meaning of the questions, no interaction between each dag no post. Consider a dag expectations delete count the number of steps.
Suppose a point there \ (x \) points (including myself) can reach him, he would have to answer \ (1 / x \) contribution. This is because the probability of this point must be deleted and delete this point by itself to delete this point is \ (1 / the X-\) , so this contribution is expected to \ (1 \ 1 Times / the X-\) .
How to count \ (the X-\) . \ (X \) is the only index after all exploded \ (GCD \) number of divisors.
At this point there are 60 points up.
Consider for \ (\ le \ sqrt n \ ) the number of violent treatment, for \ (> \ sqrt n \) number, because these numbers do not have a degree, so long considered their penetration. As is well known form \ (x ^ y \) integers it is very small, specifically, about \ (O (\ sum_ {i = 1} ^ {\ sqrt n} \ log_i n) \) is too small ! So we locate a \ (\ le \ sqrt n \ ) number, and then enumerate all of its computing power and violence can be. But to go heavy, concrete realization of a hash.
There are some out-degree penetration are \ (0 \) point directly +1
Complexity \ (O (\ text {} too easily) \)
//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<unordered_set>
using namespace std; typedef long long ll; typedef long double lb;
inline int qr(){
register int ret=0,f=0;
register char c=getchar();
while(!isdigit(c))f|=c==45,c=getchar();
while(isdigit(c)) ret=ret*10+c-48,c=getchar();
return f?-ret:ret;
}
const int maxn=1e7+5;
int n,usd[maxn],Min[maxn];
vector<int> e;
inline void pre(const int&n){
usd[1]=1; Min[1]=10;
for(int t=2;t<=n;++t){
if(!usd[t])e.push_back(t),Min[t]=t;
for(auto i:e){
if(1ll*i*t>n)break;
usd[i*t]=1,Min[i*t]=i;
if(t%i==0)break;
}
}
}
int gcd(const int&x,const int&y){return y?gcd(y,x%y):x;}
inline int getd(int x){
if(x==1)return 1;
int d=0;
while(x>1){
int g=Min[x],cnt=0;
while(x%g==0&&x>1) ++cnt,x/=g;
d=gcd(d,cnt);
}
return d;
}
int K=0;
inline lb getsig(int x){
if(x==1) return 1;
ll ret=1;
while(x>1){
K=max(K,x);
int g=Min[x],cnt=0;
while(x%g==0&&x>1) ++cnt,x/=g;
ret=ret*(cnt+1LL);
}
return (lb)1/ret;
}
unordered_set<int> s;
int main(){
pre(maxn-1);
int T=qr();
while(T--){
int n=qr(),N=sqrt(n);
lb ans=0;
for(int t=1;t<=N;++t) ans+=getsig(getd(t));
ll k=2;
for(int t=2,cnt;t<=N;k=++t){
int d=getd(t);
cnt=1;
while(k<=N) k=k*t,++cnt;
while(k<=n){
if(s.find(k)==s.end())
s.insert(k),ans+=getsig(d*cnt);
k=k*t,++cnt;
}
}
ans+=(n-N-s.size());
printf("%Lf\n",ans);
s.clear();
}
return 0;
}