Pagini recente » Cod sursa (job #2122544) | Cod sursa (job #1963036) | Cod sursa (job #2709038) | Cod sursa (job #861076) | Cod sursa (job #1997855)
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <algorithm>
using namespace std;
ifstream in("ssnd.in");
ofstream out("ssnd.out");
#define ll long long
#define pb push_back
const int inf = 1e9 + 5;
const ll NMax = 12e6 + 5;
const ll PMax = 1e6 + 5;
const int mod = 9973;
int nrPrimes;
int primes[NMax];
bool notPrime[NMax];
ll pw(ll,ll);
int main() {
primes[++nrPrimes] = 2;
for (int i=3;i <= PMax;i += 2) {
if (notPrime[i]) {
continue;
}
primes[++nrPrimes] = i;
for (int j=3*i;j <= PMax; j += 2*i) {
notPrime[j] = true;
}
}
/*
for (int i=1;i <= 27;++i) {
cout<<primes[i]<<' ';
}
*/
ll T;
in>>T;
while (T--) {
ll N;
in>>N;
ll nrDiv = 1,nrTop = 1,nrBot = 1,p;
for (int i=1;(p = primes[i]) != 0 && p*p <= N;++i) {
if (N % p != 0) {
continue;
}
int d = 0;
while (N % p == 0) {
++d;
N /= p;
}
nrDiv *= (d+1);
nrTop = (nrTop * (pw(p,d+1) - 1 + mod)) % mod;
nrBot = (nrBot * (p-1)) % mod;
}
if (N != 1) {
nrDiv *= 2;
nrTop = (nrTop * (N+1)) % mod;
}
out<<nrDiv<<' '<<(nrTop*pw(nrBot,mod-2)) % mod<<'\n';
}
in.close();out.close();
return 0;
}
ll pw(ll base,ll exp) {
ll ans = 1;
while (exp) {
if (exp & 1) {
ans = (ans * base) % mod;
}
base = (base * base) % mod;
exp >>= 1;
}
return ans;
}