Cod sursa(job #2675315)
| Utilizator | Data | 21 noiembrie 2020 13:46:33 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
#define ll long long
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
ll a, b;
ll putere_log_rec(ll a, int b)
{
if(b > 0)
{
if(b%2 ==1)
return a*putere_log_rec(a*a, b/2);
return putere_log_rec(a*a, b/2);
}
return 1;
}
int main()
{
cin >> a >> b;
cout << putere_log_rec(a, b);
return 0;
}
