Cod sursa(job #3262550)

Utilizator v4nes5aBulacu Gabriela-Vanessa v4nes5a Data 10 decembrie 2024 18:40:07
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.42 kb
#include <bits/stdc++.h>
using namespace std;

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

const int mod = 1999999973;
int n, p;

int power(int a, int b)
{
    int rez = 1;
    while(b > 0)
    {
        if(b % 2 == 1)
            rez = 1LL * rez * a % mod;
        a = 1LL * a * a % mod;
        b = b / 2;
    }
    return rez;
}

int main()
{
    fin >> n >> p;
    fout << power(n, p);
}