Cod sursa(job #1911958)

Utilizator radu.leonardoThe Doctor radu.leonardo Data 7 martie 2017 22:25:11
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.47 kb
#include <bits/stdc++.h>
#define MOD %1999999973
using namespace std;
int x,n;

long long pow(long long x,long long n)
{
    int y=1;
    while(n>1)  if(n%2) y*=x,x*=x,n/=2,x%=MOD;
                else         x*=x,n/=2,x%=MOD;

    return x*y%MOD;
}

void read()
{
    ifstream f("lgput.in");
    f>>x>>n;
    f.close();
}

void write()
{
    ofstream g("lgput.out");
    g<<pow(x,n);
    g.close();
}


int main()
{
    read();
    write();
}