Cod sursa(job #2716650)
Utilizator | Ioana Draganescu IoanaDraganescu | Data | 5 martie 2021 14:13:15 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.58 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int mod = 1999999973;
long long n, p;
void Read(){
fin >> n >> p;
}
long long LgPow(long long base, long long exponent){
long long aux = base, ans = 1;
while (exponent){
if (exponent % 2 == 1)
ans = ans * aux % mod;
exponent /= 2;
aux = aux * aux % mod;
}
return ans;
}
void Print(){
fout << LgPow(n, p) << '\n';
}
int main(){
Read();
Print();
return 0;
}