Cod sursa(job #2632579)
| Utilizator | Data | 3 iulie 2020 21:22:54 | |
|---|---|---|---|
| Problema | Suma si numarul divizorilor | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.67 kb |
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
int t, n;
void rezolva(int x)
{
int d = 2, p, nrd = 1, sum = 1;
while(x > 1)
{
p = 0;
while(x % d == 0)
{
p++;
x = x / d;
}
if(p > 0)
{
nrd = nrd * (p + 1);
sum = sum * (pow(d, p + 1) - 1) / (d - 1);
}
d++;
}
fout << nrd << " " << sum << "\n";
}
int main()
{
fin >> t;
for(int i = 1; i <= t; i++)
{
fin >> n;
rezolva(n);
}
return 0;
}
