Cod sursa(job #3210955)

Utilizator superbibiHudea P. Victor superbibi Data 7 martie 2024 19:41:36
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.3 kb
#include <fstream>
#include <cmath>
using namespace std;

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



int main(){
     long long n, p,np=1;
     fin >> n >> p;
    while(p>0){
    if(p%2==0){
        np = np * n;
    }
    np = np % 1999999973;
    n = n * n;
    p = p / 2;
    }
    fout << np;
}