Cod sursa(job #2917405)

Utilizator raresgherasaRares Gherasa raresgherasa Data 4 august 2022 19:13:28
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.33 kb
#include <bits/stdc++.h>

using namespace std;

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

const int mod = 1999999973;

long long a, b, p = 1;

int main(){
  fin >> a >> b;
  while (b > 0){
    if (b & 1){
      p = (p * a) % mod;
    }
    a = (a % mod) * (a % mod) % mod;
    b >>= 1;
  }
  fout << p;
}