Cod sursa(job #2865381)

Utilizator FasoleboiTudor Gadalean Fasoleboi Data 8 martie 2022 19:40:35
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.41 kb
#include <bits/stdc++.h>
#define mod 1999999973
#define ll long long
using namespace std;

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

ll putere(ll x, ll n){
    ll p = 1;
    while(n){
        if(n & 1){
            p = p * x % mod;
        }
        x = x * x % mod;
        n>>=1;
    }
    return p;
}

int main(){
    ll x, n;
    fin>>x>>n;
    fout<<putere(x, n);
    return 0;
}