Răspuns:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("numere.in");
ofstream g("numere.out");
int n, nr, inv, i, j, S;
f >> n;
for(i = 1; i <= n; i++){
f >> nr; S = inv = 0;
while(nr){
inv = inv * 10 + nr % 10;
nr = nr / 10;
}
for(j = 2; j <= inv / 2; j++)
if(inv % j == 0)
S = S + j;
g << S << " ";
}
f.close(); g.close();
return 0;
}