Pagini recente » Cod sursa (job #1881639) | Cod sursa (job #1309213) | Cod sursa (job #1372357) | Cod sursa (job #1147846) | Cod sursa (job #1790919)
#include <iostream>
#include <cmath>
using namespace std;
//ifstream cin("ssnd.in");
//ofstream cout("ssnd.out");
unsigned long long n,t,c,s,r,j=2; //t nr de teste ; n nr curent ; s suma curenta; c cardinalul curent; r radicalul nr curent;
bool a[1000000]; // numerele prime pina la 10^6
void primele() //calculul numerelor prime
{
int p,k;
for (int i=0; i<=1000000; i++)
{
a[i]=false;
}
for (int x=1; x<=1000; x++)
{
for (int y=1; y<=1000; y++)
{
p=4*x*x+y*y;
if (p<=1000000 && (p % 12 == 1 || p % 12 == 5)) a[p]=!a[p];
p-=x*x;
if (p<=1000000 && p % 12 == 7) a[p]=!a[p];
p-=2*y*y;
if (x>y && p<=1000000 && p % 12 == 11) a[p]=!a[p];
}
}
for (int i=5; i<=1000; i++)
{
if (a[i])
{
p=i*i;
k=p;
while (k<=1000000)
{
a[k]=false;
k+=p;
}
}
}
a[2]=true;
a[3]=true;
}
main()
{
primele();
cin >> t;
for ( ; t; t--)
{
cin >> n;
c=2; s=n+1; r=sqrt(n); j=0;
for (unsigned long long i=2; i<=r;)
{
if (j==0) j=i; else j=j*i;
if (a[i] && j<=r && n % j == 0)
{
if (j!=n/j)
{
c+=2;
s=(s+j+n/j) % 9973;
}
else
{
c+=1;
s=(s+j) % 9973;
}
}
else
{
i++;
j=0;
}
}
if (r * r == n)
{
c++;
s=(s+r) % 9973;
}
cout << c << ' ' << s << '\n';
}
}