Pagini recente » Borderou de evaluare (job #1520690) | infoarena - comunitate informatica, concursuri de programare | Cod sursa (job #3146697) | Cod sursa (job #1800146) | Cod sursa (job #2982105)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
bool v[1000001];
int main()
{
long long int n, x, nr_putere = 0, numar_div = 1, suma_divizori = 1, produs1 = 1;
v[0] = v[1] = true;
for(int i = 4; i <= 1000001; i += 2)
{
v[i] = true;
}
for(long long int i = 3; i <= 1000001/2; i += 2)
{
for(long long int j = i * i; j <= 1000001; j = j + 2 * i)
v[j] = true;
}
fin >> n;
for(long long int i = 1; i <= n; i++)
{
fin >> x;
numar_div = 1;
suma_divizori = 1;
for(long long int j = 1; j <= x; j++)
{
if(v[j] == false && x % j == 0)
{
nr_putere = 0;
while(x % j == 0)
{
nr_putere++;
x = x / j;
}
numar_div = numar_div * (nr_putere + 1);
produs1 = 1;
while(nr_putere + 1)
{
produs1 = produs1 * j;
nr_putere--;
}
suma_divizori =suma_divizori * ((produs1 - 1) / (j - 1));
}
}
fout << numar_div << " " << suma_divizori <<'\n';
}
}