Cod sursa(job #580384)

Utilizator informatician29kill03 informatician29 Data 13 aprilie 2011 01:20:58
Problema Suma si numarul divizorilor Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.37 kb
#include<fstream>
#include<math.h>
using namespace std;
ifstream f("ssnd.in");
ofstream g("ssnd.out");
int main()
{int t,n,nrdiv,sumadiv,j,fm,i=2; 
f>>t; 
for(j=1;j<=t;j++)
{
f>>n; nrdiv=sumadiv=1; fm=0; 
    do{
	while(n%i==0)
	{fm++; 
	n/=i;}
	nrdiv*=(fm+1); 	
    sumadiv*=(pow(i,(fm+1))-1)/(i-1);
	i++; 	
    }while(n!=1);
g<<nrdiv<<" "<<sumadiv<<'\n';}

}