Cod sursa(job #1291330)

Utilizator AncientHeroAncientHero99 AncientHero Data 12 decembrie 2014 18:24:24
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
#include <fstream>
using namespace std;
ifstream in("ridicare.in");
ofstream out("ridicare.out");
int main()
{
    long long int x,y,rez;
    in>>x;
    in>>y;
    rez=1;
    while(y!=0)
    {
        if(y%2==1)
        {
            rez=rez*x%1999999973;
            y--;

        }
        if(y%2==0)
        {
            x=x*x%1999999973;
            y=y/2;
        }
    }
    out<<rez%1999999973;
    return 0;
}