Cod sursa(job #2445201)
| Utilizator | Data | 3 august 2019 10:09:13 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int lgPut(int base, int exp)
{
int ans = 1;
int aux = base;
for(int i = 1; 1LL * i <= exp; i <<= 1)
{
if(i & exp)
ans = (1LL * ans * aux) % MOD;
aux = (1LL * aux * aux) % MOD;
}
return ans % MOD;
}
int main()
{
int N, P; fin >> N >> P;
fout << lgPut(N, P);
return 0;
}
