Pagini recente » Cod sursa (job #2517382) | Cod sursa (job #580989) | Cod sursa (job #3175902) | Cod sursa (job #351177) | Cod sursa (job #635214)
Cod sursa(job #635214)
#include <fstream>
using namespace std;
const int MOD = 9973;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
int N=1000005, cnt=0;
//char prim[1000005];
int p[1000005];
const int NMAX = 1 << 17;
unsigned char V[NMAX];
inline int pow(int x, int p) {
int rez = 1;
x %= MOD;
for(; p; p >>= 1) {
if(p & 1) {
rez *= x;
rez %= MOD;
}
x *= x;
x %= MOD;
}
return rez;
}
int main()
{
int t,i,j,i2,nr,e,f,p1,p2,s;
long long n;
p[++cnt]=2;
for (i = 3; i <= N; i += 2) {
if (V[i >> 4] & (1 << ((i >> 1) & 7))) continue;
p[++cnt]=i;
for (j = i + (i2 = i + i); j <= N; j += i2)
V[j >> 4] |= 1 << ((j >> 1) & 7);
}
fin>>t;
for(i=1;i<=t;i++)
{
fin>>n;
f=1; nr=1;s=1;
while(n!=1&&f<=cnt&&p[f]*p[f]<=n)
{
if(n%p[f]==0)
{
e=0;
while(n%p[f]==0)
{
n=n/p[f];
e++;
}
p1=pow(p[f],e+1);
p2=pow(p[f]-1,MOD-2);
s=(s*p1*p2)%MOD;
nr=nr*(e+1);
}
f++;
}
if(n!=1)
{
nr=nr*2;
s=(s*(n+1))%MOD;
}
fout<<nr<<" "<<s<<"\n";
}
}