Pagini recente » Rating Alexandru (idk0504) | Cod sursa (job #2262814) | Cod sursa (job #1770101) | Cod sursa (job #2147402) | Cod sursa (job #1726437)
#include <bits/stdc++.h>
void ssnd(int x, int &nr, int &sum) {
nr = 1;
sum = 1;
bool prim[x + 1];
memset(prim, true, sizeof(bool) * (x + 1));
for (int i = 2; i < sqrt(x); i++) {
for (int j = i * i; j <= x; j += i) {
if (prim[j]) {
prim[j] = false;
}
}
}
int po;
int copy = x;
for (int i = 2; i <= copy; i++) {
po = 0;
if (prim[i]) {
while (x % i == 0) {
po++;
x = x / i;
}
if (pow != 0) {
nr *= (po + 1);
sum *= ((pow(i, po + 1) - 1) / (i - 1));
}
}
if (x == 1) {
break;
}
}
}
int main() {
FILE *fin = fopen("ssnd.in", "r");
FILE *fout = fopen("ssnd.out", "w");
int n, x, sum, nr;
fscanf(fin, "%d", &n);
for (int i = 0; i < n; i++) {
fscanf(fin, "%d", &x);
ssnd(x, nr, sum);
fprintf(fout, "%d %d\n", nr, sum);
}
}