Pagini recente » Cod sursa (job #1735007) | Cod sursa (job #1767825) | Cod sursa (job #1876537) | Cod sursa (job #66153) | Cod sursa (job #2430821)
#include <iostream>
#include <fstream>
#include <vector>
#define mod 9973
std::ifstream fin("ssnd.in");
std::ofstream fout("ssnd.out");
int t;
long long n;
bool isNP[1005000];
std::vector<long long> v;
void euclid(long long a, long long b,int &x, int &y)
{
if(b==0)
{
x=1;
y=0;
}
else
{
int x0, y0;
euclid(b,a%b,x0,y0);
x= y0;
y= x0- (a/b)*y0;
}
}
int main()
{
for(int i=4;i<1000005;i+=2)
isNP[i]=true;
for(int i=3;i*i<1000005;i+=2)
for(int p=i*i;p<1000005;p+=i)
isNP[p]=true;
v.push_back(2);
for(int i=3;i<1000005;i+=2)
if(!isNP[i])
v.push_back(i);
fin>>t;
for(int i=0;i<t;i++)
{
fin>>n;
long long sum=1;
long long countt=1;
for(unsigned int j=0;j<v.size()&&v[j]*v[j]<=n;j++)
{
int c=0;
int powj=v[j];
while(n%v[j]==0)
{
c++;
n=n/v[j];
powj=(powj*v[j])%mod;
}
if(c!=0)
{
countt=(countt*(c+1))%mod;
int x, y;
euclid(v[j]-1,mod,x,y);
if(x<0)
x+=(-x/mod+1)*mod;
x=x%mod;
sum= (sum* ((powj+mod-1)%mod*x)%mod)%mod;
}
if(n==1) break;
}
if(n!=1)
{
countt=(countt*2)%mod;
int x, y;
euclid(n-1,mod,x,y);
if(x<0)
x+=(-x/mod+1)*mod;
x=x%mod;
long long powj= ((n%mod)*n)%mod;
sum= (sum* ((powj+mod-1)%mod*x)%mod)%mod;
}
fout<< countt<<" "<<sum<<"\n";
}
}