Pagini recente » Cod sursa (job #1727438) | Cod sursa (job #1653976) | Cod sursa (job #2099640) | Cod sursa (job #797007) | Cod sursa (job #1347071)
#include <iostream>
#include <fstream>
ifstream fin("snnd.in");
ofstream fout("snnd.out");
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()
{
int t,n;
fin>>t;
for(int i=1; i<=t; i++){
fin>>n;
fout<<nrdivi(n)<<' '<<sdiv(n)<<"\n";}
return 0;
}