Pagini recente » Cod sursa (job #1911801) | Cod sursa (job #3000034) | Cod sursa (job #2867787) | Cod sursa (job #2159089) | Cod sursa (job #2153082)
#include <fstream>
#define ull unsigned long long
using namespace std;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
int const MOD=9973 , nmax=1000010;
bool ci[nmax];
int v[nmax],nrd;
ull s;
ull mod(ull m)
{
return (m * m);
}
ull pow(ull base, ull exponent)
{
if(!exponent) return 1;
if(exponent == 1) return base;
return (!(exponent & 1)) ? mod(pow(base, exponent / 2)) : (base * mod(pow(base, exponent / 2)));
}
void ciur()
{
int z = 1,i;
v[0] = 2;
for(i= 3; i * i < nmax; i += 2)
{
if(!ci[i])
{
v[z++] = i;
for(int d = i * i ;d < nmax ;d += 2 * i)
ci[d] = true;
}
}
for(i;i<nmax;i+=2)
{
if(!ci[i])
v[z++]=i;
}
}
void ssnd(ull x)
{
s=1; nrd=1;
for(int i=0; x>1 && 1LL * v[i] * v[i] <= x; i++)
{
if(x%v[i]) continue;
ull p=0;
while(!(x % v[i]))
{
p++;
x /= v[i];
}
nrd *= p + 1;
s *= ((pow(v[i], p) * v[i] - 1) / (v[i] - 1)) % MOD;
}
if(x > 1) {
nrd *= 2;
s *= (x + 1) % MOD;
}
fout << nrd<<" "<< s % MOD <<'\n';
}
int main()
{
ciur();
ull x;
int n;
fin >> n;
while(n--)
{
fin >> x;
ssnd(x);
}
return 0;
}