Cod sursa(job #3356237)
| Utilizator | Data | 30 mai 2026 13:43:09 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
int n, p, k = 1, a;
fin >> n >> p;
a = n;
while (k < p)
{
n *= n;
k *= 2;
if (k * 2 > p)
{
while (k < p)
{
n *= a;
k++;
}
break;
}
}
fout << n;
}