Pagini recente » Cod sursa (job #1589201) | Cod sursa (job #2897461) | Cod sursa (job #502269) | Cod sursa (job #42547) | Cod sursa (job #1834459)
#include <iostream>
#include <cstdint>
#include <cmath>
using namespace std;
int64_t exponentiere(int N, int P){
if(N > 1999999973)
N = N % 1999999973;
int64_t rez;
if(P == 0)
return 1;
if(P == 1)
return N;
if(P%2 == 0)
return (exponentiere(N, P/2)) % 1999999973 * (exponentiere(N, P/2)) % 1999999973 ;
else
return (N *(exponentiere((N*N) % 1999999973, (P-1)/2))) % 1999999973 ;
}
int main(){
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
long long N, P;
cin >> N >> P;
cout << exponentiere(N, P) % 1999999973;
return 0;
}