Cod sursa(job #1991069)

Utilizator alex2704Pirvuceanu Alexandru alex2704 Data 14 iunie 2017 21:21:05
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long x,y;;
void power(long long x, long long y, long long p)
{
    long long res = 1;

    x = x % p;

    while (y > 0)
    {

        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    g<<res;
}
int main()
{f>>x>>y;
   long long m=1999999973;
   power(x,y,m);
}