Cod sursa(job #2573283)

Utilizator DobondiDavidDobondiDavid DobondiDavid Data 5 martie 2020 16:51:01
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.33 kb
#include <fstream>

using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define mod 1999999973
int n,p,sol;
int main()
{
    fin >> n >> p;
    sol = 1;
    while (p)
    {
        if (p%2!=0)
            sol=sol*n%mod;
        n=n*n%mod;
        p=p/2;
    }
    fout << sol;
    return 0;
}