Cod sursa(job #799518)

Utilizator enedumitruene dumitru enedumitru Data 19 octombrie 2012 10:24:43
Problema Suma si numarul divizorilor Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 1.37 kb
#include <fstream>
#define LL long long
#define MOD 9973
using namespace std;
int t,nr;
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 <= 1000000; ++i) 
		if (w[i] == 0) 
		{	r[++nr]=i;
			for (j = i + i; j <= 1000000; j += i) w[j] = 1;
		}	
	}
inline LL calc(LL a, int k)
{ 	LL p=a;
	while(--k) p*=a;
	return p;
}
/*
#include<cstdio>
#define N 1999999973
long long int n,p;
long long int exp()
{
	long long int rez=1,i,q=n;
	for(i=p;i;i>>=1)
	{
		if(i&1)
		{
			rez*=q;
			rez%=N;
		}
		q*=q;
		q%=N;
	}
	return rez;
}
int main()
{
	freopen("lgput.in","r",stdin);
	freopen("lgput.out","w",stdout);
	scanf("%d%d",&n,&p);
	printf("%d",exp());
	return 0;
}
*/
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];
			}
			d++;
			prod = calc(r[i],d)-1;
			prod = (prod / (r[i]-1)) % MOD;
			sum = (sum * prod) % MOD;
			nrdiv = nrdiv * d;
		}
		i++;
	}
	if(n>1) 
		{	nrdiv = nrdiv * 2;
			sum = (sum * (n+1)) % MOD;
		}
	g<<nrdiv<<' '<<sum<<'\n';
}

int main()
{
	ciur();
	f >> t;
	while(t--)
	{
		f >> n;
		desc( n );
	}
	g.close(); return 0;
}