Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <algorithm>
- using namespace std;
- vector<bool>prime(50000001,true);
- void Ciur(int n)
- {
- prime[0]=prime[1]=false;
- for(int p=2;p*p<=n;++p)
- if(prime[p])
- for (int i=p*2;i<=n;i+=p)
- prime[i]=false;
- }
- int main()
- {
- int n;
- ifstream f("primcolor.in");
- f>>n;
- f.close();
- ofstream g("primcolor.out");
- if(n<=3)
- {
- g<<n;
- return 0;
- }
- Ciur(n);
- int sol=2,vstart=n/2+1,vend=n+1;
- for(int i=vstart;i<vend;++i)
- if(prime[i])
- ++sol;
- g<<sol;
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement