Cod sursa(job #2329673)

Utilizator SochuDarabaneanu Liviu Eugen Sochu Data 27 ianuarie 2019 11:31:52
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.4 kb
#include <fstream>
#define modulo 1999999973
using namespace std;
ifstream f ("lgput.in");
ofstream g("lgput.out");
long long int nlaput,n,p,rez=1,cif;
int main()
{
    f>>n>>p;
    rez=1;
    nlaput=n;
    while(p)
    {
        cif=p%2;
        p/=2;
        if(cif==1)
            rez=(nlaput * rez) % modulo;
        nlaput=(nlaput*nlaput)%modulo;
    }
    g<<rez;
    return 0;
}