Cod sursa(job #582754)

Utilizator informatician28Andrei Dinu informatician28 Data 15 aprilie 2011 20:43:26
Problema Suma si numarul divizorilor Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.82 kb
#include<fstream> 
#include<cmath>
using namespace std; 
ifstream f("ssnd.in");
ofstream g("ssnd.out");
long long putere,sumad,i,nr;
long long ridicare(long long baza,long long expo) 
{int k;
putere=1;
for(k=1;k<=expo+1;k++) 
	putere*=baza; 
return putere; 
}
int prim(long long numar) 
{int ok,d;
ok=1; 
for(d=2;d<=sqrt(numar);d++) 
	if(numar%d==0) ok=0; 
return ok; 
}
int main() 
{int j,t,fm,nrd,ok;
f>>t;
for(i=1;i<=t;i++) 
{f>>nr; nrd=sumad=1; ok=0;
for(j=1;j<=nr;j++)   
  {fm=0;      
     if(nr%j==0 && prim(j))        
     {while(nr%j==0) {nr/=j; fm++;} 
     nrd*=(fm+1); sumad*=(ridicare(j,fm)-1)/(j-1);       
}        
if(prim(nr) && ok==0) {fm=ok=1;  nrd*=(fm+1); sumad*=(ridicare(nr,fm)-1)/(nr-1);                      
}        
}

g<<nrd<<" "<<sumad%9973<<'\n'; 
}
return 0; 
}