F.A.Qs Home ProblemSet Status Ranklist Contest LoginRegister
大视野在线测评-欢迎您
[ New Thread ]
Problem 2440 >> 求助 提交CE
kczno1 @ 2017-05-14 16:07:25
[ Quote ] [ Edit ] [ Delete ] 1#
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mid (l+r>>1)
const ll U=1644934081LL;
const int N=(int)sqrt((double)U);//如果把这里改成数字就不会ce了
int miu[N+5],pr[N],*top=pr,*head,i,x;
bool vis[N+5];

ll xiao_deng(const ll &n)
{
ll ans=0;
for(ll i=1;i*i<=n;++i) ans+=miu[i]*n/(i*i);
return ans;
}

int main()
{


miu[1]=1;
for(i=2;i<=N;++i)
{
if(!vis[i]) { miu[i]=-1;*++top=i; }
for(head=pr+1;i*(x=*head)<=N;++head)
{
vis[i*x]=1;
if(!(i%x)) { miu[i*x]=0;break; }
miu[i*x]=-miu[i];
}
}

int tt;scanf("%d",&tt);
while(tt--)
{
int k;
scanf("%d",&k);
if(k==1){puts("1");continue;}
ll l=1,r=U;
while(l+1!=r)
if(xiao_deng(mid)>=k) r=mid;
else l=mid;
printf("%lld\n",r);
}
}
ccc000111 @ 2017-05-14 16:27:14
[ Quote ] [ Edit ] [ Delete ] 2#
cmath库……
kczno1 @ 2017-05-14 16:36:14
[ Quote ] [ Edit ] [ Delete ] 3#
你是说 #include<cmath> ?
还是ce啊
ccc000111 @ 2017-05-14 16:41:57
[ Quote ] [ Edit ] [ Delete ] 4#
还有很多库,貌似bits/stdc++.h用不了
ccc000111 @ 2017-05-14 16:42:58
[ Quote ] [ Edit ] [ Delete ] 5#
你把你的编译错误信息发一下
zhanghengrui @ 2019-12-07 15:32:54
[ Quote ] [ Edit ] [ Delete ] 6#
很多编译器只能在运行时求sqrt
但是定义数组只能用编译时常量作为大小
wemspzc @ 2019-12-10 15:32:01
[ Quote ] [ Edit ] [ Delete ] 7#
Orzkcz
Ynoi @ 2019-12-22 21:35:12
[ Quote ] [ Edit ] [ Delete ] 8#
kcz黑历史?
[Top] [Previous Page] [Next Page]

HOME Back