Pagini recente » Cod sursa (job #817400) | Cod sursa (job #2534884) | Cod sursa (job #1933473) | Cod sursa (job #1426401) | Cod sursa (job #1347073)
#include <iostream>
#include <fstream>
using namespace std;
int putere(int a, int b){
int p=1;
for(int i=1; i<=b; i++)
p=p*a;
return p;
}
int nrdivi(int n){
int nrdiv=1, exp, d=2;
while(n>1){
exp=0;
while(n%d==0){
n=n/d;
exp++;
}
d++;
nrdiv=nrdiv*(exp+1);
}
return nrdiv;
}
int sdiv(int n){
int nrdiv=1, exp, d=2, suma=1;
while(n>1){
exp=0;
while(n%d==0){
n=n/d;
exp++;
}
d++;
nrdiv=nrdiv*(exp+1);
if(exp!=0) suma=suma*((putere(d,exp+1)-1)/(d-1));
}
return suma;
}
int main()
{
ifstream fin("snnd.in");
ofstream fout("snnd.out");
int t,n;
fin>>t;
for(int i=1; i<=t; i++){
fin>>n;
fout<<nrdivi(n)<<' '<<sdiv(n)<<"\n";}
return 0;
}