Pagini recente » Cod sursa (job #301857) | Cod sursa (job #2058656) | Cod sursa (job #2616396) | Cod sursa (job #2174967) | Cod sursa (job #756966)
Cod sursa(job #756966)
#include <fstream>
using namespace std;
long long put (long long a, long long b, long long mod) {
if (a == 1) return 1 % mod;
if (b == 0) return 1 % mod;
if (b == 1) return a % mod;
long long temp = put (a, b >> 1, mod);
temp = (temp * temp) % mod;
if (b & 1) temp = (temp * a) % mod;
return temp;
}
int invers (int val, int coprim) {
return put (val % coprim, coprim - 2, coprim);
}
int calcul_suma_progresie (int q, int n, int mod) {
if (q % mod == 1) return (n + 1) % mod;
else {
return ((put (q, n + 1, mod) + 9900) * (invers (q - 1, mod))) % mod;
}
}
int main () {
int a, b, t, p, s = 1, mod = 9901;
ifstream f ("sumdiv.in");
ofstream g ("sumdiv.out");
f >> a >> b;
for (p = 2; p * p <= a; ++ p) {
t = 0;
while (a % p == 0) {
a /= p;
++ t;;
}
if (t > 0) {
s = (s * calcul_suma_progresie (p, t * b, mod)) % mod;
}
}
if (a > 1) {
s = (s * calcul_suma_progresie (a, b, mod)) % mod;
}
g << s << endl;
return 0;
}