Pagini recente » Cod sursa (job #266646) | Cod sursa (job #2090402) | Cod sursa (job #2566607) | Cod sursa (job #1853316) | Cod sursa (job #1834460)
#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 % 1999999973) * (exponentiere(N, (P-1)/2)) % 1999999973 * (exponentiere(N, (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;
}