Cod sursa(job #2190405)

Utilizator SochuDarabaneanu Liviu Eugen Sochu Data 30 martie 2018 18:07:15
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.39 kb
#include <fstream>

using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
long long int n,p,nlaputere,rez;
int main()
{
    fin>>n>>p;
    nlaputere=n;
    rez=1;
    while(p)
    {
        if(p%2==1)
            rez=(rez*nlaputere)%1999999973;
         p/=2;
         nlaputere=(nlaputere*nlaputere)%1999999973;

    }
    fout<<rez;


        return 0;
}