2025-01-28 15:20:04 -06:00

38 lines
642 B
C++

#include <cstdio>
#include <iostream>
#include <cmath>
int main() {
int t;
std::scanf("%d", &t);
while (t--) {
int n;
std::scanf("%d", &n);
if (n == 1) {
std::cout << "0" << std::endl;
continue;
}
int total = 1;
int r = (int) std::floor(std::sqrt(n));
for (int n2 = 2; n2 < r + 1; n2++) {
if (n % n2 == 0) {
int other = n / n2;
if (other != n)
total += other;
total += n2;
}
}
std::cout << total << std::endl;
}
return 0;
}