Cod sursa(job #2711971)

Utilizator cristiemanuelstroe cristian emanuel cristiemanuel Data 24 februarie 2021 23:45:46
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include  <iostream>
#include  <fstream>

using namespace std;

const int mod = 1999999973;

ifstream fin("lgput.in");
ofstream fout("lgput.out");

int lgput(int x, int y) {
  int rez = 1;
  int exp = x;
  while (y) {
    if (y & 1)
       rez = 1LL * rez * exp, rez %= mod;
    exp = 1LL * exp * exp;
    exp %= mod;
    y >>= 1;
  }
  return rez;
}

int main() {
  int x, y;
  fin>>x>>y;
  fout<<lgput(x, y);
}