Cod sursa(job #2874868)
Utilizator | stroe cristian emanuel cristiemanuel | Data | 20 martie 2022 13:41:49 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
const int mod = 1999999973;
long long x, y;
long long lgput(long long x, long y) {
long long r = 1;
while(y) {
if (y & 1)
r = (r * x) % mod;
x = (x * x) % mod;
y >>= 1;
}
return r;
}
int main()
{
in>>x>>y;
out<<lgput(x, y);
}