Cod sursa(job #2753257)
Utilizator | Data | 22 mai 2021 09:11:09 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
typedef long long ll;
const ll MOD=2e9-17;
ll pw(ll x, ll y)
{
ll ans=1;
for(;y;y>>=1,x=x*x%MOD)
if(y&1)
ans=ans*x%MOD;
return ans;
}
int main()
{
ll x,y;
fin>>x>>y;
fout<<pw(x,y);
return 0;
}