Cod sursa(job #3227485)
Utilizator | Data | 1 mai 2024 13:13:12 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int lgput(int base, int exp) {
if (exp==0) {
return 1;
}
if (exp%2==0) {
int half=lgput(base,exp/2);
return half*half;
}
return base*lgput(base,exp-1);
}
int main() {
int n,p;
fin >> n >> p;
fout << lgput(n,p)%1999999973;
}