Cod sursa(job #2490063)

Utilizator WilIiamperWilliam Damian Balint WilIiamper Data 9 noiembrie 2019 18:06:45
Problema Divizori Primi Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.09 kb
#include <fstream>
#include <bitset>
#define MAX 1000005

using namespace std;
ifstream fin ("divprim.in");
ofstream fout ("divprim.out");
int n, t, k, prim[MAX];
bitset <MAX> ciur;

int div () {
    bool found = false; int x = n;
    int p, l, x_copy, nr;
    while (found == false && x > 1) {
        nr = 0; l = 1;
        x_copy = x;
        while (x_copy > 1) {
            p = 0;
            while (x_copy % prim[l] == 0) {
                x_copy /= prim[l];
                p++;
            }
            if (p > 0)
                nr++;
            l++;
        }
        if (nr == k)
            found = true;
        x--;
    }
    return x+1;
}

void eratostene() {
    int l = 1;
    prim[l++] = 2;
    for (int i = 3; i < MAX; i += 2)
    if (!ciur[i]) {
        prim[l++] = i;
        fout << prim[l-1] << " ";
        for (int j = i * i; j < MAX; j += i)
            ciur[j] = 1;
    }
}

int main()
{
    eratostene();
    /*fin >> t;
    for (int i = 1; i <= t; i++) {
        fin >> n >> k;
        fout << div() << "\n";
    }*/
    return 0;
}