Cod sursa(job #2772198)

Utilizator AACthAirinei Andrei Cristian AACth Data 31 august 2021 11:21:23
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.08 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
#define cin f
#define cout g

void nos()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
namespace SieveOfEratosthenes{

	const int limita = 2e6 + 1;
	vector < int > divisors[limita];
	int firstdiv[limita];
	bitset < limita > primes;
	void precompute(int limit)
	{
		int cnt = 0;
		primes.set();
		int i,j;
		for(i=2;i<=limit;++i)
		{
			if(primes[i] == true)
			{
				cnt ++;
				//firstdiv[i] = i;
				divisors[i].push_back(i);
				for(j=2*i;j<=limit;j+=i)
				{
					primes[j] = false;
					//if(firstdiv[j] == 0)
					//	firstdiv[j] = i;
					//divisors[j].push_back(i);
				}
			}
		}
		g<<cnt;
	}
	vector < int > get_div(int n)
	{
		return divisors[n];
	} 
	int get_first_div(int n)
	{
		return firstdiv[n];
	}
}
int n;
void read()
{
	f>>n;
	SieveOfEratosthenes::precompute(n);
}
void solve()
{
    
}
void restart()
{

}
int32_t main()
{
    nos();

        read();
        solve();
        restart();
    
    return 0;
}