显然的区间筛法
#include#include #include #include using namespace std;typedef long long ll;ll L,R,k,n;const int MAXN = 10000005;int prime[MAXN],tot;bool isx[MAXN];void mkprime(){ for(int i=2;i<=n;i++){ if(!isx[i]){prime[++tot]=i;} for(int j=1;i*prime[j]<=n&&j<=tot;j++){ int v=prime[j]; isx[i*v]=1; if(i%v==0)break; } }}bool vis[MAXN];int main(){ freopen("prime.in","r",stdin); freopen("prime.out","w",stdout); cin>>L>>R>>k; n=sqrt(R); n=min(n,k); mkprime(); for(int i=1;i<=tot;i++){ int v=prime[i]; ll cur=1ll*v*(L/v); if(cur