Cod sursa(job #2983067)

Utilizator bitza1247Stanciu-Tivlea Valentin Gabriel bitza1247 Data 21 februarie 2023 15:28:11
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.42 kb
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ifstream f("lgput.in");
ofstream g("lgput.out");

ll a,b,mod=1999999973;

int fastexp(ll a,ll b)
{
    ll r=1;
    while(b)
    {
        if(b%2==1)
        {
            r=(r*a)%mod;
            b--;
        }
        b=b/2;
        a=(a*a)%mod;
    }
    return r;
}
int main()
{
    f>>a>>b;
    g<<fastexp(a,b);
    return 0;
}