Cod sursa(job #2252102)

Utilizator ImbuzanRaduImbuzan Radu ImbuzanRadu Data 2 octombrie 2018 12:15:16
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda musai_must Marime 0.37 kb
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    ifstream f("lgput.in");
    ofstream g("lgput.out");
    long long a,n;
    f>>a>>n;
    long long sol = 1;
    for(long long i = 1; i < (1 << 30); i = i * 2)
    {
      if(n & i) sol = (sol * a) % 1999999973;

      a = (a * a) % 1999999973;
    }
    g<<sol ;
    return 0;
}