Cod sursa(job #2587977)

Utilizator mara.gheorghe21@gmail.comCheeki Breeki [email protected] Data 23 martie 2020 23:07: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;
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)
    {
        if (k&1)
            r=(1LL*n*r)%Rest;
        n*=(1LL*n)%Rest;
        k/=2;
    }
    out<<r;
    return 0;
}