[题解]提高day7

这场暴力分好多啊~~~

T1奇怪的队列

T2质数

没什么好说的

代码:

ll n,cnt,l,r,s[11000000],sum[11000000],kkk[11000000];
bool su[11000000];
void shai(ll n){
	for (ll i=2;i<=n;i++){
		if(!su[i])s[++s[0]]=i,kkk[i]=1;
		for (ll j=1,x;j<=s[0]&&(x=i*s[j])<=n;j++){
			su[x]=1;
			kkk[x]=kkk[i]+1;
			if(i%s[j]==0)break;
		}
	}
}
void solve(){
	l=read();r=read();
	writeln(sum[r]-sum[l-1]);
}
int main(){
	IO::file();
	shai(10100000);
	rep(i,2,10100000)sum[i]=sum[i-1]+(bool)(kkk[i]<=2);
	n=read();
	while(n--)solve();
	IO::flush();
}

T3好文章

posted @ 2020-08-05 16:22  ZTC_ZTC  阅读(71)  评论(0编辑  收藏  举报