Cod sursa(job #1481648)
| Utilizator | Data | 5 septembrie 2015 00:05:36 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 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;
if (k % 2 == 1)
return n * pow(n * n, k / 2) % mod;
else
return pow(n * n, k / 2) % mod;
}
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%lld %lld", &n, &k);
printf("%lld", pow(n, k));
return 0;
}
