Pagini recente » Cod sursa (job #2758561) | Cod sursa (job #1647636) | Cod sursa (job #2599536) | Cod sursa (job #2742410) | Cod sursa (job #2042042)
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
const long long NMax = 1000005;
const long long mod = 9973;
char ciur[NMax];
vector < long long > primes;
long long N;
pair < long, long > euclid_extins(long long x, long y)
{
if(y==0)
{
return {1,0};
}
auto aux = euclid_extins(y,x%y);
long long rap = x/y;
return {aux.second, aux.first - rap * aux.second};
}
void Ciuruletz()
{
primes.push_back(2);
for(long long i=3; i<=NMax; i+=2)
{
if(!ciur[i])
{
primes.push_back(i);
for(long long j=i; j*i<=NMax; j+=2)
ciur[i*j] = 1;
}
}
}
long long RidExp(long long nr, long long put)
{
long long rez = 1;
do
{
if(put & 1)
rez = (nr*rez)%mod;
nr = (nr*nr)%mod;
put = put >> 1;
}
while(put);
return rez;
}
void Solve(long long x)
{
long long ind = 0;
long long nr_div = 1;
long long sum = 1;
while(primes[ind] * primes[ind] <= x)
{
long long po = 0;
while(x%primes[ind] == 0)
{
++po;
x/=primes[ind];
}
if(po)
{
nr_div *= 1LL * (po+1);
long long pk = primes[ind];
long long nom = (RidExp(1LL * pk % mod,(1LL * po+1)%mod) - 1)%mod;
long long nr = (1LL * euclid_extins(1LL * pk - 1,1LL * mod).first)%mod;
while(nr<0)
{
nr+=1LL * mod;
}
sum *= nom/nr;
}
++ind;
}
if(x!=1)
{
nr_div *= 1LL * 2;
sum *= 1LL * (x+1) % mod;
}
fout << nr_div%mod << " " << sum%mod << "\n";
}
void Read()
{
long long t;
fin >> t;
for(long long i=1; i<=t; ++i)
{
long long x;
fin >> x;
Solve(x);
}
}
int main()
{
Ciuruletz();
Read();
return 0;
}