# sol

$F(i)=\sum_{i|d}^{n}f(d)$

$f(1)=\sum_{i=1}^{\sqrt n}\mu(i)\lfloor \frac {n}{i^2} \rfloor$

## code

#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
const int N = 1000005;

int gi()
{
int x=0,w=1;char ch=getchar();
while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
if (ch=='-') w=0,ch=getchar();
while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
return w?x:-x;
}

int mu[N+5],zhi[N+5],pri[N+5],tot;
void Mobius()
{
mu[1]=1;zhi[1]=1;
for (int i=2;i<=N;i++)
{
if (!zhi[i]) pri[++tot]=i,mu[i]=-1;
for (int j=1;j<=tot&&i*pri[j]<=N;j++)
{
zhi[i*pri[j]]=1;
if (i%pri[j]) mu[i*pri[j]]=-mu[i];
else {mu[i*pri[j]]=0;break;}
}
}
}
ll check(ll mid)
{
ll res=0;
for (ll i=1;i*i<=mid;i++)
res+=mu[i]*(mid/(i*i));
return res;
}
int main()
{
Mobius();
int T=gi();
while (T--)
{
ll k=gi();
ll l=0,r=k*10;
while (l<r)
{
ll mid=(l+r)>>1;
if (check(mid)>=k) r=mid;
else l=mid+1;
}
printf("%lld\n",l);
}
return 0;
}

posted @ 2018-01-08 22:12  租酥雨  阅读(194)  评论(2编辑  收藏  举报