Cod sursa(job #2582678)
| Utilizator | Data | 17 martie 2020 11:43:53 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int p(int b, int e)
{
if(e==1) return b%1999999973;
else
{
if(e%2==0) return p(b,e/2)*p(b,e/2)%1999999973;
else return b*p(b,(e-1)/2)*p(b,(e-1)/2)%1999999973;
}
}
int n,k;
int main()
{
//cout << sizeof(v)*1.0/1024;
fin >> n >> k;
fout << p(n,k);
return 0;
}
