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