Pagini recente » Diferente pentru utilizator/mihnea.anghel intre reviziile 15 si 43 | Cod sursa (job #1762284) | Monitorul de evaluare | Diferente pentru home intre reviziile 453 si 454 | Cod sursa (job #1985540)
#include <fstream>
using namespace std;
ifstream f("sumdiv.in");
ofstream g("sumdiv.out");
int a, b;
const int mod = 9901;
long long lgput(long long base, long long exp);
long long IM(int x)
{
return lgput(x, mod - 2);
}
long long lgput(long long base, long long exp)
{
long long rez = 1;
while (exp)
{
if (exp % 2)
{
rez = (rez * base) % mod;
exp--;
}
base = base * base % mod;
exp /= 2;
}
return rez;
}
int RepairMod(int x)
{
while (x < 0)
{
x += mod;
}
return x;
}
void sum(int a, int b)
{
long long s = 1;
int d = 0, p;
while (a % 2 == 0)
{
a /= 2;
d++;
}
if (d)
s = (s * (RepairMod(lgput(2, d*b + 1) - 1))) % mod;
for (p = 3; p*p <= a; p += 2)
{
d = 0;
while (a % p == 0)
{
a /= p;
d++;
}
if (d > 0)
{
if ((p - 1) % mod == 0)
{
int aux = (d*b + 1) % mod;
s = s * aux % mod;
}
else
{
s = (s*(RepairMod((lgput(p, d*b + 1) - 1)) * IM(p - 1) % mod)) % mod;
}
}
}
if (a != 1)
{
if ((a - 1) % mod == 0)
{
int aux = (b + 1) % mod;
s = s*aux %mod;
}
else
{
s = (s* ((RepairMod(lgput(a, b + 1) - 1)) * IM(a - 1) % mod)) % mod;
}
}
g << s << "\n";
}
int main()
{
f >> a >> b;
sum(a, b);
f.close();
g.close();
return 0;
}