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