Cod sursa(job #2900008)

Utilizator cristiemanuelstroe cristian emanuel cristiemanuel Data 9 mai 2022 21:22:16
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.44 kb
#include  <iostream>
#include  <fstream>

# define ll unsigned long long
using namespace std;

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

const int mod = 1999999973;

ll Ceface(int x, int n) {

  if (n == 0)
    return 1;
  if  (n % 2 == 1)
    return (1LL * x * Ceface(x, n - 1))% mod;
  // ll res = Ceface(x, n / 2);
  return  (1LL*Ceface(x, n / 2) *  Ceface(x, n / 2))%mod;
}

int main() {
  int x, n;
  in>>x>>n;
  out<<Ceface(x, n);
}