Cod sursa(job #2690445)
Utilizator | Data | 23 decembrie 2020 23:36:56 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <iostream>
#define modulo 1999999973
using namespace std;
long long putere(long long n,long long p)
{
if(p==0)return 1;
if(p%2) return n*putere(n,p-1)%modulo;
else return putere(n*n,p/2)%modulo;
}
int main()
{
long long n,p;
cin>>n>>p;
cout<<putere(n,p);
}