Cod sursa(job #2675318)
Utilizator | Data | 21 noiembrie 2020 13:47:49 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.44 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)%MOD;
return putere_log_rec(a*a, b/2)%MOD;
}
return 1;
}
int main()
{
fin >> a >> b;
fout << putere_log_rec(a, b);
return 0;
}