Cod sursa(job #1481649)
| Utilizator | Data | 5 septembrie 2015 00:15:46 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
#include <cstdio>
#include <cstdlib>
using namespace std;
const int mod = 1999999973;
#define ll long long
ll n, k;
ll pow(ll n, ll k) {
if (k == 0)
return 1;
if (k == 1)
return n % mod;
if (k % 2 == 1)
return n * pow(n * n % mod, k / 2) % mod;
else
return pow(n * n % mod, k / 2) % mod;
}
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%lld %lld", &n, &k);
printf("%lld\n", pow(n, k));
return 0;
}
