Cod sursa(job #2433867)
Utilizator | Data | 29 iunie 2019 15:58:21 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.34 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*x,(n-1)/2)%M);
return pow((x%M)*(x%M),n/2)%M;
}
int main()
{
cin>>n>>p;
cout<<pow(n%M,p%M);
}