Cod sursa(job #2581713)
| Utilizator | Data | 15 martie 2020 17:53:27 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 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)
{
ll m=putere(x,n/2);
return ((m%mod)*(m%mod))%mod;
}
{
ll m=putere(x,(n-1)/2);
return ((x%mod)*((m%mod)*(m%mod))%mod)%mod;
}
}
int main() {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin >> a >> b;
fout<<putere(a, b);
return 0;
}
