Pagini recente » Cod sursa (job #1085790) | Cod sursa (job #631913) | Cod sursa (job #420353) | Cod sursa (job #1713453) | Cod sursa (job #1064325)
# include <fstream>
# include <algorithm>
# include <bitset>
# include <cmath>
# define N_Max 1000000
using namespace std;
ifstream f("ssnd.in");
ofstream g("ssnd.out");
bitset <1000005> p;
long long a[200000];
long long i,j,k,n,VV,d,ndiv,suma,nr,ap,inm;
long long x,X;
long long putere (long long w, long long q)
{
long long QQ=1;
w=w%9973;
while (q!=0)
{
if (q%2==1)
{
QQ=QQ*w;
--q;
}
else
{
w=w*w;
q=q/2;
}
w=w%9973;
QQ=QQ%9973;
}
return QQ;
}
int main ()
{
a[1]=2;
k=1;
for (i=3; i<=N_Max; i=i+2)
{
if (p[i]==0)
{
a[++k]=i;
for (j=3; i*j<=N_Max; j=j+2)
p[i*j]=1;
}
}
f>>n;
for (i=1; i<=n; ++i)
{
f>>x; X=x;
nr=0; ndiv=1; suma=1;
for (j=1; j<=k && a[j]*a[j]<=X && x!=0; ++j)
{
if (x%a[j]==0)
{
ap=0;
while (x%a[j]==0)
{
++ap;
x=x/a[j];
}
ndiv=ndiv*(ap+1);
inm=putere(a[j],ap+1)-1;
suma=(suma*((inm/(a[j]-1))%9973))%9973;
}
}
if (x>1)
{
g<<"2 "<<(x+1)%9973<<"\n";
continue;
}
g<<ndiv<<" "<<suma<<"\n";
}
return 0;
}