Cod sursa(job #1135658)

Utilizator iordache.bogdanIordache Ioan-Bogdan iordache.bogdan Data 8 martie 2014 10:09:23
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;

const long long modulo = 1999999973;

long long a,b,p;

ifstream f("lgput.in");
ofstream g("lgput.out");

int main() {
    f>>a>>b;
    p=1;
    while(b!=0) {
        if((b&1LL)==1) {
            p*=a;
            p%=modulo;
        }
        b>>=1LL;
        a*=a;
        a%=modulo;
    }
    g<<p%modulo<<"\n";
    return 0;
}