Pagini recente » Cod sursa (job #1723494) | Cod sursa (job #71219) | Cod sursa (job #1057040) | Cod sursa (job #1601883) | Cod sursa (job #972874)
Cod sursa(job #972874)
#include <fstream>
#include <vector>
#include <bitset>
#define ll long long
const int max = 1000005;
const int M = 9973;
std::vector<int> myV;
std::bitset<max> bC;
int pow(int x, int p)
{
int rez = 1;
x %= M;
for(; p; p >>= 1)
{
if(p & 1)
{
rez *= x;
rez %= M;
}
x *= x;
x %= M;
}
return rez;
}
void make()
{
for(int i = 2; i < max; i++)
if(bC[i] == 0)
{
myV.push_back(i);
for(int j = i + i; j < max; j += i)
bC[j] = 1;
}
}
int main()
{
make();
std::ifstream in("ssnd.in");
std::ofstream out("ssnd.out");
int nV;
in >> nV;
ll nB,nC;
for(int i = 0; i < nV; i++)
{
in >> nB;
nC = nB;
int nr(1), sum(1);
for(unsigned j(0); j < myV.size() && 1LL * myV[j] * myV[j] <= nB; j++)
if(nB % myV[j] == 0)
{
int k(0);
while(nB % myV[j] == 0)
{
k++;
nB /= myV[j];
}
nr *= k + 1;
int p1 = (pow(myV[j], k + 1) - 1) % M;
int p2 = pow(myV[j] - 1, M - 2) % M;
sum = (((sum * p1) % M) * p2) % M;
}
if(nB > 1)
{
nr *= 2;
sum = (1LL * sum * (nB + 1) % M);
}
out << nr << ' ' << sum << "\n";
}
}