Cod sursa(job #1953928)

Utilizator MarianConstantinMarian Constantin MarianConstantin Data 5 aprilie 2017 09:23:10
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.38 kb
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    ifstream fin ("lgput.in");
    ofstream fout ("lgput.out");
    unsigned long long a, p, pr, nr=1;
    fin >> a >> p;
    pr=a;
    while (p)
    {
        if (p%2)
            nr=nr*pr%1999999973;
        pr=pr*pr%1999999973;
        p/=2;
    }
    fout << nr%1999999973;
    return 0;
}