Cod sursa(job #2248847)

Utilizator haila2Nume complet haila2 Data 29 septembrie 2018 13:39:11
Problema Divizori Primi Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    int T, N, K;
    ifstream f("divprim.in");
    ofstream g("divprim.out");
    f>>T;


    while (f>>N)
    {
        int nr_div=0, cx, d;
        while (cx!=-1)
        {
            cx=N;
            d=2;
            while (cx>1)
            {
                while (cx%d==0)
                    nr_div++, cx/=d;
            }
            d++;
            f>>K;
            if (nr_div==K)
                g<<N<<endl, cx=-1;
            else
                N--;
        }
        if (cx!=-1)
            g<<'0';
    }


    return 0;
}