Cod sursa(job #2339675)

Utilizator darksky185Alexandru Gabriel darksky185 Data 9 februarie 2019 11:04:58
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.38 kb
#include<fstream>

using namespace std;

ifstream cin("lgput.in");
ofstream cout("lgput.out");

#define mod 1999999973

int main()
{
    long long x, rez = 1;
    int n, m;
    cin >> x >> n;
    for( m = 1; m <= n; m *= 2 )
    {
        if( ( n & m ) != 0 )
            rez = 1ll* rez * x % mod;
        x = 1ll* x * x;
    }
    cout << rez;

    return 0;
}