Cod sursa(job #2274712)
Utilizator | Data | 2 noiembrie 2018 12:54:05 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
using namespace std;
typedef long long LL;
const LL MOD = 1999999973;
LL raise(LL x, LL p) {
LL ans;
for (ans = 1; p; p >>= 1) {
if (p & 1)
ans = (ans * x) % MOD;
x = (x * x) % MOD;
}
return ans;
}
int main() {
std::ifstream in("lgput.in");
std::ofstream out("lgput.out");
LL a, b;
in >> a >>b;
out << raise(a % MOD, b);
return 0;
}