Cod sursa(job #2776666)
Utilizator | Data | 20 septembrie 2021 17:20:47 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
typedef long long ll;
const ll mod=1999999973;
ll power(ll a,ll b)
{
ll ans=1;
while(b)
{
if(b&1) ans=(ans*a)%mod;
a=(a*a)%mod;
b>>=1;
}
return ans;
}
int main()
{
ll a,b;
in>>a>>b;
out<<power(a,b)<<'\n';
return 0;
}