Cod sursa(job #2700748)

Utilizator cyg_mihaizMIHAI ZARAFIU cyg_mihaiz Data 28 ianuarie 2021 17:39:51
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.45 kb
#include <fstream>

using namespace std;
typedef long long ll;
const int MOD = 1999999973;

ifstream fin("lgput.in");
ofstream fout("lgput.out");

int main()
{
    ios_base::sync_with_stdio(false);
    fin.tie(NULL);

    ll ans = 1;
    int n,m,i;
    fin >> n >> m;
    for(i = 1; i <= m; i <<= 1)
    {
        if(m & i)
            ans = (1LL * ans * n) % MOD;
        n = (1LL * n * n) % MOD;
    }
    fout << ans;
    return 0;
}