Cod sursa(job #2675316)

Utilizator Cezar211Popoveniuc Cezar Cezar211 Data 21 noiembrie 2020 13:46:55
Problema Ridicare la putere in timp logaritmic Scor 10
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()
{
    fin >> a >> b;
    fout << putere_log_rec(a, b);
    return 0;
}