Cod sursa(job #2124703)
Utilizator | Data | 7 februarie 2018 15:03:25 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int a, n;
inline int Pow(int a, int n)
{
int p = 1;
while(n > 0)
{
if(n % 2 == 1)
p = (1ll * p * a) % MOD;
n /= 2;
a = (1LL * a * a) % MOD;
}
return p;
}
int main()
{
fin >> a >> n;
fout << Pow(a, n);
return 0;
}