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