Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
624 B
3
Indexable
Never
#include<iostream>
using namespace std;
int ary[100000000];
void test(){
	for(long long int i=0;i<100000000;i++){
		if(i%2==0){
			ary[i]=0;
		}
		else{
			ary[i]=1;
		}
	}
	ary[0]=0;
	ary[1]=0;
	ary[2]=1;
	for(long long int i=3;i<100000000;i+=2){
		if(ary[i]==0){
			continue;
		}
		long long int p=i;
		p+=p;
		while(p<100000000){
			ary[p]=0;
			p+=i;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	test();
	int a,b;
	while(cin>>a>>b){
		long long int sum=0;
		for(long long int i=a;i<=b;i++){
			if(ary[i]==1){
				sum++;
			}
		}
		cout<<sum<<endl;
	}
	
	
}