Pagini recente » Istoria paginii runda/imded2/clasament | Transport | Cod sursa (job #814456) | Istoria paginii runda/preonisim2008/clasament | Cod sursa (job #1851519)
#include <fstream>
using namespace std;
ifstream fin ( "ssnd.in" );
ofstream fout ( "ssnd.out" );
bool c[1000001];
int a[1000001];
int main()
{ int n, i, ct = 0, s, j, ctdiv;
long long x;
c[2] = 1;
for ( i = 3; i <= 1000000; i = i + 2 )
c[i] = 1;
for ( i = 1; i * i <= 1000000; i++ )
if ( c[i] == 1 )
for ( j = i * 3; j <= 1000000; j = j + 2 * i )
c[j] = 0;
for ( i = 1; i <= 1000000; i++ )
if ( c[i] == 1 )
{ ct++;
a[ct] = i;
}
fin >> n;
for ( i = 1; i <= n; i++ )
{ fin >> x;
ctdiv = 2;
s = x + 1;
for ( j = 1; j * j <= x; j++ )
if ( x % a[j] == 0 )
{ ctdiv++;
s = s + a[j];
if ( x / a[j] != a[j] ) { ctdiv++; s = s + x / a[j]; }
}
fout << ctdiv << " " << s << "\n";
}
fin.close();
fout.close();
return 0;
}