Cod sursa(job #2385271)

Utilizator petrisorvmyVamanu Petru Gabriel petrisorvmy Data 21 martie 2019 19:03:45
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda excelenta-tema2 Marime 0.41 kb
#include <fstream>
#define MOD 1999999973
#define ll long long
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
ll a, b;
ll put(ll a, ll b)
{
    ll rez=1;
    while(b)
    {
        if(b%2)
            rez= (rez*a)%MOD;
        a= (a*a) % MOD;
        b/=2;
    }
    return rez;
}
int main()
{
    f>> a >> b;
    g<< put(a,b);
    g.close();
    f.close();
    return 0;
}