Cod sursa(job #2433869)
Utilizator | Data | 29 iunie 2019 16:15:31 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
using namespace std;
ifstream cin("lgput.in");
ofstream cout("lgput.out");
#define M 1999999973
#define ll long long
ll n,p;
ll pow(ll x,ll n)
{
if (n==1) return x%M;
if (n%2) return ((x%M)*(pow(((x%M)*(x%M))%M,(n-1)/2)%M))%M;
return pow(((x%M)*(x%M))%M,n/2)%M;
}
int main()
{
cin>>n>>p;
cout<<pow(n,p)%M;
}