Cod sursa(job #2248955)

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

int main()
{
    ifstream f("divprim.in");
    ofstream g("divprim.out");
    int t,n,k,ok,aux,d,nr;
    f>>t;
   while(f>>n)
    {
       ok=1; f>>k;
        while(n>0&&ok==1)
        {
             aux=n; d=2; nr=0;
            while(aux>1)
            {
                if(aux%d==0)
                {
                    nr++;
                    while(aux%d==0)
                        aux=aux/d;
                }
                d++;
            }
            if(nr==k)
            {
                g<<n<<'\n';
                ok=0;

            }
            n--;
        }
         if(ok==1)
            g<<"0"<<'\n';
    }
    f.close();
    g.close();

    return 0;
}