Cod sursa(job #1723661)
Utilizator | Data | 1 iulie 2016 12:11:08 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
#define ll long long
#define M 1999999973
using namespace std;
ll power(ll n, ll p) {
if(p==0)
return 1;
if (p==1)
return n;
ll pow=(power(n,p/2));
if(p%2==0)
return (pow*pow)%M;
else
return ((((pow*pow)%M)*n)%M);
}
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll n,p;
fin>>n>>p;
fout<<power(n,p);
return 0;
}