Cod sursa(job #2818815)

Utilizator Stefanstef99Stefan Puica Stefanstef99 Data 16 decembrie 2021 22:26:35
Problema Divizori Primi Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("divprim.in");
ofstream fout("divprim.out");

int c,n,k;
int ciur[1000005],nrdiv[1000005],ans[8][1000005];

int main()
{
    int i,j,poz=0;
    for(i=2;i<=1000000;i++)
    {
        if(ciur[i]==0)
        {
            for(j=i;j<=1000000;j+=i)
            {
                nrdiv[j]++;
                ciur[j]=1;
            }
        }
    }
    for(k=0;k<8;k++)
    {
        poz=0;
        for(i=1;i<=1000000;i++)
        {
            if(nrdiv[i]==k)
            {
                poz=i;
            }
            ans[k][i]=poz;
        }
    }
    fin>>c;
    while(c--)
    {
        fin>>n>>k;
        fout<<ans[k][n]<<"\n";
    }
    return 0;
}