Pagini recente » Cod sursa (job #2922319) | Cod sursa (job #2049205) | Cod sursa (job #1942305) | Cod sursa (job #3293563) | Cod sursa (job #972745)
Cod sursa(job #972745)
#include <fstream>
#include <cmath>
#include <vector>
#define max 100000
std::vector<int> make()
{
bool bC[max];
std::vector<int> myV;
for(int i(0); i < max; i++)
bC[i] = true;
for(int i = 2; i <= sqrt(max); i++)
if(bC[i])
for(int j = i * i; j < max; j += i)
bC[j] = false;
for(int i = 2; i < max; i++)
if(bC[i]) myV.push_back(i);
return myV;
}
int main(void)
{
std::vector<int> myV = make();
std::ofstream out("ssnd.out");
std::ifstream in("ssnd.in");
int nV;
in >> nV;
long long unsigned nB;
for(int i = 0; i < nV; i++)
{
in >> nB;
int sum(1);
long long unsigned prod(1);
long long unsigned cop = nB;
for(unsigned j(0); j < myV.size() && myV[j] <= sqrt(nB); j++)
{
if(cop % myV[j]) continue;
int k(1);
long long unsigned l(myV[j]);
while(cop % myV[j] == 0)
{
cop /= myV[j];
l *= myV[j];
k++;
}
sum *= k;
prod *= (l - 1) / (myV[j] - 1);
}
if(sum == 1) sum++;
if(prod == 1) prod += nB;
out << sum << ' ' << prod << "\n";
}
return 0;
}