Pagini recente » Cod sursa (job #2294839) | Cod sursa (job #37680) | Cod sursa (job #742002) | Cod sursa (job #1271007) | Cod sursa (job #1853587)
#include <iostream>
#include <cmath>
#include <bitset>
using namespace std;
int const radmax = 1000001;
int const nmax = 1001;
int const modulo = 9973;
bitset<radmax> ciur; //ciur[i] == true <=> composed number
int primes[radmax], nprimes;
long long n;
void computeciur() {
ciur[0] = ciur[1] = 1;
ciur[2] = ciur[3] = 0;
primes[0] = 2;
primes[1] = 3;
nprimes = 2;
for (int i = 4; i < radmax; i += 2) {
ciur[i] = 1;
}
for (int i = 5; 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);
}
}
inline 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() {
int invers, y;
int ndiv = 1, sumadiv = 1;
scanf("%lld", &n);
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) * invers2) % modulo;
}
i++;
}
if (1 < n) {
ndiv *= 2;
sumadiv = (1LL * sumadiv * (n + 1)) % modulo;
}
printf("%d %d\n", ndiv, sumadiv);
//debug
// for (int i = 0; i < nfactor; i++) {
// cout << factor[i] << "^" << power[i] << endl;
// }
}
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++) {
decompose();
}
return 0;
}