Cod sursa(job #2270333)
| Utilizator | Data | 27 octombrie 2018 10:34:08 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <bits/stdc++.h>
#define ll long long
#define M 1999999973
using namespace std;
ll n , p;
ll putere(ll x , ll n)
{
ll a ;
if (n == 0) return 1;
if (n == 1) return x;
a = putere(x , n / 2);
if (n % 2 == 0) return(a*a)%M;
else return ((x*a)%M*a)%M;
}
int main()
{
freopen("lgput.in" , "r" , stdin);
freopen("lgput.out" , "w" , stdout);
scanf("%lld%lld" , &n , &p);
ll q = putere(n , p) % M ;
printf("%lld" , q);
return 0;
}
