Pagini recente » Cod sursa (job #505220) | Cod sursa (job #1549545) | Cod sursa (job #864414) | Cod sursa (job #394466) | Cod sursa (job #2682664)
#include <bits/stdc++.h>
#define MOD 1999999973
#define int long long
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int lgput(int baza, int exponent)
{
//3 11
//11 = (1) * 2 ^ 3 + (0) * 2 ^ 2 + (1) * 2 ^ 1 + (1) * 2 ^ 0
int ans = 1, aux = baza;
for(int i = 1; i <= exponent; i *= 2)
{
if((exponent & i) != 0) /// daca bitul i apare in descompunere
{
ans *= aux;
ans %= MOD;
}
aux *= aux;
aux %= MOD;
}
return ans;
}
int32_t main()
{
int N, P;
fin >> N >> P;
fout << lgput(N, P);
return 0;
}