Cod sursa(job #2159386)
Utilizator | Data | 10 martie 2018 21:49:39 | |
---|---|---|---|
Problema | Suma si numarul divizorilor | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.63 kb |
#include<fstream>
#include<cmath>
#include<iostream>
using namespace std;
ifstream f("ssnd.in");
ofstream g("ssnd.out");
long long n,x;
void calc()
{
if(x==1) {g<<"1 1\n"; return;}
long long s=1,nr=1,d=2;
while(x!=1)
{
if(x%d==0)
{
long long p=0;
while(x)
{
p++;
x/=d;
}
nr*=p+1;
s*=(pow(d,p+1)-1/d-1);
}
d++;
}
g<<s<<" "<<nr<<endl;
}
int main()
{
f>>n;
for(int i=1;i<=n;i++)
{
f>>x;
calc();
}
return 0;
}