Cod sursa(job #639881)

Utilizator pandreeaePopescu Andreea pandreeae Data 24 noiembrie 2011 09:40:36
Problema Suma si numarul divizorilor Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.82 kb
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin ("ssnd.in");
ofstream fout ("ssnd.out");
bool v[1000001]={0};

 void ciur()
 {
	for(int i=3;i<=1000000;i+=2){
	if(v[i]==0){
		for(int j=2*i; j<=1000000; j+=i)
			v[j]=1;}}
 }
 
 void desco(long long x)
 {
	long long nr, sum, t, i, exp, aux;
	aux=x;
	nr=sum=1;
	for(i=3; i*i<=aux ;i+=2){
		if(v[i]==0 && x%i==0){
		exp=1;
		t=i;
		while(x%i==0){
			exp++;
			x=x/i;
			t=t*i;}
		nr*=exp;
		sum*=(t-1)/(i-1)%9973;}}
	if(x%2==0){
			exp=1;
			t=2;
			while(x%2==0){
				exp++;
				x=x/2;
				t=t*2;}
			nr*=exp;
			sum*=(t-1)%9973;}
	if(x!=1){
		sum*=(x*x-1)/(x-1)%9973;
		nr*=2;}
	sum=sum%9973;
	fout<<nr<<' '<<sum<<endl;
 }
 
int main()
{
	long long n, q;
	fin>>n;
	while(n--){
		fin>>q;
		desco(q);}
	return 0;
}