Pagini recente » Cod sursa (job #1418995) | Cod sursa (job #2670437) | Cod sursa (job #1246413) | Cod sursa (job #1932117) | Cod sursa (job #1612617)
#include <stdio.h>
#include<vector>
#include<math.h>
#define PRIM 1000001
#define SQprim 1001
#define esteprim(i) P[i]==false
#define LL long long
using namespace std;
bool P[PRIM];
LL n,m,i,t,j,x,ok,SQ,SUM,PROD,p,P1,P2;
LL putere (LL x, LL y)
{
if (y==0)
return 1;
return putere(x,y-1)*x;
}
int main()
{
freopen ("ssnd.in","r",stdin);
freopen ("ssnd.out","w",stdout);
scanf ("%lld",&t);
vector <LL> V;
for (i=2;i<SQprim;i++)
if (esteprim(i))
{
V.push_back(i);
for (j=i*2;j<PRIM;j+=i)
P[j]=true;
}
for (i=SQprim;i<PRIM;i++)
if (esteprim(i))
V.push_back(i);
for (;t>0;t--)
{
scanf ("%lld",&x);
ok=0;
SQ=sqrt(x);
PROD=1;
SUM=1;
P1=P2=1;
for (i=0;V[i]<=PRIM&&x>1;i++)
if (x%V[i]==0)
{
ok=1;
p=0;
j=V[i];
while (x%j==0)
{
p++;
x/=j;
}
PROD*=p+1;
SUM*=(putere(j,p+1)-1);
SUM/=j-1;
}
if (ok)
{
printf ("%lld %lld\n",PROD,SUM%9973);
}
else
if (x==1)
printf ("1 1\n");
else
printf ("2 %lld\n",x+1);
}
return 0;
}