Pagini recente » Cod sursa (job #2602078) | Cod sursa (job #946825) | Cod sursa (job #2190449) | Cod sursa (job #1266140) | Cod sursa (job #2042036)
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
const int NMax = 1000005;
const int mod = 9973;
char ciur[NMax];
int primes[NMax];
int 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()
{
for(int i=3; i<=1005; i+=2)
{
if(!ciur[i])
for(int j=i; j*i<=1005; j+=2)
ciur[i*j] = 1;
}
int k = 0;
primes[++k] = 2;
for(int i=3; i<=NMax; i+=2)
if(ciur[i] == 0)
primes[++k] = i;
}
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(int x)
{
int ind = 1;
long long nr_div = 1;
long long sum = 1;
while(primes[ind] * primes[ind] <= x)
{
int po = 0;
while(x%primes[ind] == 0)
{
++po;
x/=primes[ind];
}
if(po)
{
nr_div *= 1LL * (po+1);
int pk = primes[ind];
long long nom = RidExp(1LL * pk,1LL * po+1) - 1;
long long nr = 1LL * euclid_extins(1LL * pk - 1,1LL * mod).first;
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 << " " << sum << "\n";
}
void Read()
{
int t;
fin >> t;
for(int i=1; i<=t; ++i)
{
int x;
fin >> x;
Solve(x);
}
}
int main()
{
Ciuruletz();
Read();
return 0;
}