Cod sursa(job #3203148)

Utilizator suimerchantsui merchant suimerchant Data 13 februarie 2024 10:10:33
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.39 kb
#include <iostream>
#include <fstream>
#define mod 1999999973
using namespace std;


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


long long n,p;


int main()
{
    fin>>n>>p;
    int x=1;
    while(p)
    {
        if(p%2)
        {
            x=(1LL*x*n)%mod;
            p--;
        }
        x=(1LL*x*x)%mod;
        p/=2;
    }
    fout<<x;
    return 0;
}