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