Pagini recente » Cod sursa (job #2024011) | Cod sursa (job #1311418) | Cod sursa (job #1007095) | Cod sursa (job #415649) | Cod sursa (job #1417532)
#include <iostream>
#include <cstdio>
#include <cmath>
#define MOD 9973
#define dmax 1000000
using namespace std;
bool ciur[dmax]; int T; long long N,N_1;
void CIUR()
{
ciur[0]=1; ciur[1]=1;
for(int i=2; i<=sqrt(dmax); i++)
{
if(ciur[i]==0)
{
for(int j=2; j*i<=dmax; j++) ciur[i*j]=1;
}
}
}
long long Exp_log(long long x, long long y) //CALCULAM x^y PRIN RIDICARE LA PUTERE IN TIMP LOGARITMIC
{
long long answer=1;
while(y)
{
if(y&1) answer=answer*x%MOD;
x=x*x%MOD;
y >>= 1;
}
return answer;
}
int main()
{
freopen("ssnd.in", "r", stdin);
freopen("ssnd.out", "w", stdout);
int i,k,e; bool GASIT; long long Nd,Sd;
CIUR();
scanf("%d",&T);
for(i=1; i<=T; i++)
{
scanf("%lld",&N); Nd=1; Sd=1;
N_1=N;
for(k=2; k<=N; k++)
{
if(ciur[k]==0) //k e prim
{
e=0; GASIT=0;
while(N_1%k==0) {N_1=N_1/k; e++; GASIT=1;}
if(GASIT)
{
Nd=Nd*(e+1);
Sd=Sd*((Exp_log(k,e+1)-1)/(k-1))%MOD;
}
}
}
printf("%lld %lld\n",Nd,Sd);
}
return 0;
}