Pagini recente » Cod sursa (job #2353904) | Cod sursa (job #799502)
Cod sursa(job #799502)
#include <fstream>
#define LL long long
#define MOD 9973
using namespace std;
int t,nr = 1;
LL n,nrdiv;
ifstream f("ssnd.in");
ofstream g("ssnd.out");
const int MAXSIZE = 1000001;
int r [80000];
char w [MAXSIZE]; //w[i] == 0 if i is prime
inline void ciur()
{ int i, j;
for (i = 2; i <= 500000; ++i)
if (w[i] == 0)
for (j = i + i; j <= 1000000; j += i) w[j] = 1;
r[1] = 2;
for( int i = 3; i <= 1000000; i+=2 )
{
if(!w[i]) //cout << i << ' ',
r[++nr] = i;
}
}
inline LL calc(LL a, int k)
{ LL p=a;
for(int i=2; i<=k; ++i) p *=a;
return p;
}
inline void desc( LL n )
{ int i = 1,d;
LL nrdiv=1,prod,sum=1;
while(n > 1 && i<=nr)
{ if(!(n%r[i]))
{
d = 0; prod=1;
while(!(n%r[i]))
{ d++;
n/=r[i];
//prod *= r[i];
}
//prod = prod * r[i] -1;
prod = calc(r[i],d+1)-1;
prod = (prod / (r[i]-1)) % MOD;
sum = (sum * prod) % MOD;
nrdiv = nrdiv * (d+1);
}
i++;
}
g<<nrdiv<<' '<<sum<<'\n';
}
int main()
{
ciur();
f >> t;
while(t--)
{
f >> n;
desc( n );
}
g.close(); return 0;
}