Cod sursa(job #2849049)
Utilizator | Data | 14 februarie 2022 14:01:30 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.27 kb |
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
int main() {
long long int A, n, p = 1;
in >> A >> n;
while (n != 0) {
int c = n % 2;
if (c == 1)
p = p * A;
n = n / 2;
A = A * A;
} out << p;
return 0;
}