Pagini recente » Plantatie | Cod sursa (job #1947717) | Cod sursa (job #2456974) | Cod sursa (job #3131306) | Cod sursa (job #634331)
Cod sursa(job #634331)
#include<fstream>
const int Nmax = 1000000005;
const int MOD = 9937;
using namespace std;
char ciur[Nmax];
int nn;
int n;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
void Ciur ()
{
long long i = 0 ,j = 0;
for(i=4; i<=nn; i+=2)
ciur[i]='1';
for(i=3; i<=nn; i+=2)
if(ciur[i] == 0 )
{
j = i*i;
for( ; j<=nn; j += (i+i))
if(ciur[j] == 0)
ciur[j]='1';
}
}
int t[1003];
void ReadData()
{
fin>>n;
for( int i=0;i<n;i++)
{
fin>>t[i];
if( nn < t[i])
nn = t[i];
}
}
void Sol()
{
int i,j;
int x,aux;
int nr_div;
int putere;
for( i = 0; i<n; i++)
{
int nr=1;
int suma=1;
x = t[i];
j=2;
aux = x;
if( ciur[aux] == 0)
{
nr = 2;
suma = aux+1;
}
else
{
if( aux % j == 0 )
{
nr_div = 0;
putere = 1;
while( aux % j == 0)
{
putere *= j;
nr_div ++ ;
aux = aux /j;
}
suma = suma * ((putere * j - 1) / (j-1));
nr = nr * (nr_div + 1);
}
for( j = 3; j*j <= x; j += 2)
{
if( ciur[j] == 0)
{
aux = x;
if( aux % j == 0 )
{
nr_div = 0;
putere = 1;
while( aux % j == 0)
{
putere *= j;
nr_div ++ ;
aux = aux /j;
}
suma = suma * ((putere * j - 1)%MOD / (j-1));
suma = suma % MOD;
nr = nr * (nr_div + 1);
}
}
}
}
fout<<nr<<" "<<suma<<"\n";
}
}
int main()
{
ReadData();
Ciur();
Sol();
fout.close();
fin.close();
return 0;
}