Pagini recente » Cod sursa (job #958495) | Cod sursa (job #1719199) | Cod sursa (job #2108143) | Cod sursa (job #701939) | Cod sursa (job #1853602)
#include <iostream>
#include <cmath>
#include <bitset>
using namespace std;
int const radmax = 1000001;
int const modulo = 9973;
bitset<radmax> ciur; //ciur[i] == true <=> composed number
int primes[radmax], nprimes;
void computeciur() {
ciur[0] = ciur[1] = 1;
ciur[2] = 0;
primes[0] = 2;
nprimes = 1;
for (int i = 3; i < radmax; i += 2) {
if (ciur[i] == 0) {
primes[nprimes] = i;
nprimes++;
if (1LL * i * i < radmax) {
int j = i * i;
while (j < radmax) {
ciur[j] = 1;
j += i;
}
}
}
}
}
void gcd(int &x, int &y, int a, int b) {
if (!b)
x = 1, y = 0;
else {
gcd(x, y, b, a % b);
long aux = x;
x = y;
y = aux - y * (a / b);
}
}
int pow(int x, int p) {
int rez = 1;
x %= modulo;
for (; p; p >>= 1) {
if (p & 1) {
rez *= x;
rez %= modulo;
}
x *= x;
x %= modulo;
}
return rez;
}
void decompose(long long n) {
int invers, y;
int ndiv = 1, sumadiv = 1;
int i = 0;
while (i < nprimes && (primes[i] * primes[i] <= n)) {
if (n % primes[i] == 0) {
int npow = 0;
while (n % primes[i] == 0) {
npow++;
n /= primes[i];
}
ndiv *= npow + 1;
int powerterm = (pow(primes[i], npow + 1) - 1) % modulo;
// int invers2 = pow(primes[i] - 1, modulo - 2) % modulo;
gcd(invers, y, primes[i] - 1, modulo);
if (invers <= 0)
invers = modulo + invers % modulo;
sumadiv = (((sumadiv * powerterm) % modulo) * invers) % modulo;
}
i++;
}
if (1 < n) {
ndiv *= 2;
sumadiv = (1LL * sumadiv * (n + 1)) % modulo;
}
printf("%d %d\n", ndiv, sumadiv);
}
int main() {
freopen("ssnd.in", "rt", stdin);
freopen("ssnd.out", "wt", stdout);
computeciur();
int t;
scanf("%d", &t);
for (int i = 0; i < t; i++) {
long long n;
scanf("%lld", &n);
decompose(n);
}
return 0;
}