Pagini recente » Cod sursa (job #833724) | Cod sursa (job #1594732) | Cod sursa (job #534642) | Cod sursa (job #2265915) | Cod sursa (job #2811167)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int putere(int a, int b, int c) {
if (b == 0) {
return 1 % c;
}
if (b == 1) {
return a % c;
}
if (b % 2 == 0) {
return (putere(a, b/ 2, c) * putere(a, b/ 2, c)) % c;
} else {
return (a * putere(a, b - 1, c)) % c;
}
}
int main() {
int a, b;
fin >> a >> b;
fout << putere(a, b, 1999999973);
return 0;
}