Pagini recente » Cod sursa (job #1576342) | Cod sursa (job #832929) | Cod sursa (job #1165610) | Cod sursa (job #926521) | Cod sursa (job #1959720)
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#define MaxN 100005
#define MaxL 1000005
#define MOD 9973
using namespace std;
FILE*IN,*OUT;
long long Primes[MaxN],N;
int T,Stack[MaxN],Exp[MaxN],Size=0,PrimeCnt=0;
bool Sieve[MaxL];
void Precalc_Sieve()
{
for(int i=2;i<MaxL;i++)
if(!Sieve[i])
{
Primes[++PrimeCnt]=i;
for(int j=2*i;j<MaxL;j+=i)
Sieve[j]=true;
}
}
long long LogPow(long long base,long long exp)
{
long long ans=1;
for(int i=0;i<15;i++)
{
if(exp&(1<<i))
ans=(ans*base)%MOD;
base=(base*base)%MOD;
}
return ans;
}
void Factorize(long long X)
{
Size=0;
for(int i=1;Primes[i]<=X;i++)
{
if(Primes[i]*Primes[i]>X)
{
Stack[++Size]=X;
Exp[Size]=1;
X=1;
}
else if(X%Primes[i]==0)
{
Stack[++Size]=Primes[i];
Exp[Size]=0;
while(X%Primes[i]==0)
Exp[Size]++,X/=Primes[i];
}
}
long long Cnt=1,Sum=1;
for(int i=1;i<=Size;i++)
Cnt*=Exp[i]+1,Sum=(((Sum*(LogPow(Stack[i],Exp[i]+1)-1))%MOD)*LogPow(Stack[i]-1,MOD-2))%MOD;
fprintf(OUT,"%lld %lld\n",Cnt,Sum);
}
int main()
{
IN=fopen("ssnd.in","r");
OUT=fopen("ssnd.out","w");
Precalc_Sieve();
fscanf(IN,"%d",&T);
for(int t=1;t<=T;t++)
{
fscanf(IN,"%lld",&N);
Factorize(N);
}
return 0;
}