Cod sursa(job #1956088)
| Utilizator | Data | 6 aprilie 2017 14:46:13 | |
|---|---|---|---|
| Problema | Suma si numarul divizorilor | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.86 kb |
#include <fstream>
using namespace std;
ifstream f("ssnd.in");
ofstream g("ssnd.out");
unsigned long long int n,contor,nd,Suma,x,p,d,puterea;
int i,j;
int main()
{
f>>n;
for(i=1; i<=n; i++)
{
f>>x;
nd=1;
Suma=1;
d=2;
contor=2;
while(d*d<=x&&x!=1)
{
p=0;
while(x%d==0)
{
p++;
x/=d;
}
if(p)
{
nd*=(p+1);
puterea=1;
for(j=1; j<=p+1; j++)
puterea*=d;
Suma*=((puterea-1)/(d-1));
}
d++;
contor++;
}
if(x!=1)
{
nd*=2;
Suma*=((x*x-1)/(x-1));
}
g<<nd<<' '<<Suma<<'\n';
}
return 0;
}
