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