Cod sursa(job #2175594)
Utilizator | Data | 16 martie 2018 17:59:29 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
using namespace std;
const int mod=1999999973;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long b,e;
long long Exp(long long b,long long e)
{
if(e==0)
return 1;
if(e==1)
return b;
if(e%2==0)
return Exp((b*b)%mod,e/2)%mod;
else
return b*(Exp((b*b)%mod,(e-1)/2))%mod;
}
int main()
{
f>>b>>e;
g<<Exp(b,e);
return 0;
}