Cod sursa(job #2706937)

Utilizator tomaionutIDorando tomaionut Data 16 februarie 2021 09:39:52
Problema Divizori Primi Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <bits/stdc++.h>
#define N 1000000
using namespace std;

ifstream fin("divprim.in");
ofstream fout("divprim.out");
int d[N+5],n,a[N+5][10];
int main()
{
    int i,j,x,k;
    fin >> n;
    for (i=2; i<=N; i++)
    {
        if (d[i]==0)
        for (j=i; j<=N; j+=i)
        d[j]++;
    }
    for (i=2; i<=N; i++)
    {
        for (j=0; j<=7; j++)
            a[i][j]=a[i-1][j];
        a[i][d[i]]=i;
    }
    while (n--)
    {
        fin >> x >> k;
        fout << a[x][k] << "\n";
    }


    return 0;
}