Cod sursa(job #3250729)
Utilizator | Data | 23 octombrie 2024 13:47:48 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
uint_fast32_t n, p, x, k;
int main()
{
ios_base::sync_with_stdio(false);
fin.tie(nullptr);
fout.tie(nullptr);
fin >> n >> p;
for(k=x=1; k <= p; k <<= 1)
{
if(p&k) x *= n;
n *= n;
}
fout << x;
}