Cod sursa(job #1939896)

Utilizator StefanUrsacheStefan Ursache StefanUrsache Data 26 martie 2017 09:39:30
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.34 kb
#include <fstream>
#define m 1999999973

using namespace std;

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

int n, p;
unsigned long long xlaputere;

int main()
{
    f>>n>>p;
    xlaputere = n;
    while(p>1) {
        xlaputere = (xlaputere * xlaputere) % m;
        p/=2;
    }
    g<< xlaputere << '\n';
    return 0;
}