Cod sursa(job #2711970)
Utilizator | stroe cristian emanuel cristiemanuel | Data | 24 februarie 2021 23:45:22 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <iostream>
#include <fstream>
using namespace std;
const int mod = 1999999973;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int lgput(int x, int y) {
int rez = 1;
int exp = x;
while (y) {
if (y & 1)
rez = 1LL * rez * exp, rez %= mod;
exp = 1LL * exp * exp;
exp %= mod;
y >>= 1;
}
return rez;
}
int main() {
int x, y;
in>>x>>y;
out<<lgput(x, y);
}