Cod sursa(job #2785450)
| Utilizator | Data | 18 octombrie 2021 18:20:56 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
#define PRIME 1999999973
#define ll long long
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll pow(ll n, ll k)
{
if (k == 0)
{
return 1;
}
if (k % 2 == 0)
{
return pow((n * n) % PRIME, k >> 1);
}
else
{
return (n * pow(n, --k)) % PRIME;
}
}
ll n, k;
int main()
{
fin >> n >> k;
fout << pow(n, k);
return 0;
}
