Cod sursa(job #2587981)

Utilizator mara.gheorghe21@gmail.comCheeki Breeki [email protected] Data 23 martie 2020 23:10:29
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.34 kb
#include <fstream>

using namespace std;
const int Rest=1999999973;
int main()
{
    int n,k,r;
    ifstream in("lgput.in");
    ofstream out("lgput.out");
    in>>n>>k;
    r=1;
    while (k!=0)
    {
        if (k%2==1)
            r=(1LL*n*r)%Rest;
        n=(1LL*n*n)%Rest;
        k/=2;
    }
    out<<r;
    return 0;
}