Cod sursa(job #2526099)
| Utilizator | Data | 18 ianuarie 2020 11:45:16 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a, b;
ll mod=1999999973;
ll putere(ll x, ll n ){
if(n==0)
return 1;
if(n==1)
return x%mod;
if(n%2==0)
return ((putere(x,n/2)*putere(x,n/2))%mod);
return ((x*putere(x,(n-1)/2)*putere(x,(n-1)/2))%mod);
}
int main() {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin >> a >> b;
fout<<putere(a, b);
return 0;
}
