Cod sursa(job #2375564)
| Utilizator | Data | 8 martie 2019 10:41:03 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
const long long R = 1999999973;
long long n, p;
long long put(long long ex) {
if(ex==0)
return 1;
long long p = put(ex/2);
if(ex%2==1)
return 1LL*(p*p)%R*1LL*n%R;
else
return 1LL*(p*p)%R;
}
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>n>>p;
fout << put(p);
return 0;
}
