Cod sursa(job #3338775)

Utilizator DariusJohnDarius Dumitrescu DariusJohn Data 4 februarie 2026 23:22:51
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.44 kb
#include <bits/stdc++.h>
#include <fstream>
#define int long long
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;

int power(int base, int exp) {
  int ans = 1;
  while (exp) {
    if (exp & 1)
      ans = (ans * base) % MOD;
    exp /= 2;
    base = (base * base) % MOD;
  }
  return ans;
}

signed main() {
  int base, exp;
  fin >> base >> exp;

  fout << power(base, exp);
  return 0;
}