Cod sursa(job #1861137)
Utilizator | Data | 28 ianuarie 2017 17:02:49 | |
---|---|---|---|
Problema | Divizori Primi | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.69 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("divprim.in");
ofstream out("divprim.out");
int ciur[1000005],n,k,t,a[8][1000005];
int main()
{
for(int i=2;i<=1000000;i++)
{
if(ciur[i]==0)
{
for(int j=2*i;j<=1000000;j+=i)
ciur[j]++;
ciur[i]=1;
}
}
for(int i=1;i<=7;i++)
{
for(int j=2;j<=1000000;j++)
{
if(ciur[j]==i)
a[i][j]=j;
else
a[i][j]=a[i][j-1];
}
}
in>>t;
for(int i=1;i<=t;i++)
{
in>>n>>k;
out<<a[k][n]<<'\n';
}
return 0;
}