Cod sursa(job #1680208)
| Utilizator | Data | 8 aprilie 2016 16:12:06 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <cstdio>
using namespace std;
const int MOD = 1999999973;
typedef long long ll;
ll x, n;
ll lgput(ll x, int n)
{
ll p = 1 ;
while (n > 0)
{
if (n & 1)
{
p *= x;
p %= MOD;
n--;
}
x *= x;
n >>= 1;
}
return p ;
}
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%lld %lld", &x, &n);
printf("%lld", lgput(x, n));
return 0;
}
