Pagini recente » Cod sursa (job #1946318) | Cod sursa (job #3040299) | Cod sursa (job #2236275) | Cod sursa (job #259399) | Cod sursa (job #1468196)
#include <fstream>
using namespace std;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
const int MAXP = 1000010;
const int MOD = 9973;
bool ciur[MAXP];
int p[MAXP], np;
long long N;
int T;
void NrPrime();
void Calc( long long a, int& s, int& nd );
int Power( int a, int e );
int main()
{
int i, j;
int s;
int nd;
NrPrime();
fin >> T;
for ( i = 1; i <= T; i++ )
{
fin >> N;
Calc( N, s, nd );
fout << nd << ' ' << s << '\n';
}
fin.close();
fout.close();
return 0;
}
void NrPrime()
{
int i, j;
for ( i = 2; i * i < MAXP; i++ )
if ( !ciur[i] )
{
p[++np] = i;
for ( j = i * 2; j < MAXP; j += i )
ciur[j] = 1;
}
for ( ; i < MAXP; i++ )
if ( !ciur[i] )
p[++np] = i;
}
void Calc( long long a, int& s, int& nd )
{
int i, d; s = 1, nd = 1;
int n1, n2;
for ( i = 1; p[i] * p[i] <= a && a > 1; i++ )
{
if ( a % p[i] )
continue;
d = 0;
while ( a % p[i] == 0 )
a /= p[i], d++;
nd *= ( d + 1 );
n1 = ( Power( p[i], ( d + 1 ) ) - 1 ) % MOD;
n2 = ( Power( p[i] - 1, MOD - 2 ) % MOD );
s = ( ( ( s * n1 ) % MOD ) * n2 ) % MOD;
}
if ( a > 1 )
{
nd *= 2;
// n1 = ( Power( a, 2 ) - 1 ) % MOD;
// n2 = ( Power( a - 1, MOD - 2 ) % MOD );
s = ( 1LL * s * ( a + 1 ) ) % MOD;
}
}
int Power( int a, int e )
{
int rez = 1;
a %= MOD;
while ( e > 0 )
{
if ( e % 2 )
{
rez = ( rez * a ) % MOD;
e--;
}
a = ( a * a ) % MOD;
e /= 2;
}
return rez;
}