Cod sursa(job #3342016)

Utilizator ana_vintila123Ana Vintila ana_vintila123 Data 22 februarie 2026 14:24:03
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.38 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int main()
{
    int n, p, rez = 1;
    fin>>n>>p;

    while (p != 0) {

        if (p % 2 == 1) {

            rez = (rez*n)%MOD;
        }

        n = (n*n)%MOD;
        p /= 2;
    }

    fout<<rez;
    return 0;
}