Cod sursa(job #2761858)

Utilizator orevveronica orev Data 4 iulie 2021 12:45:14
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.42 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream in ("lgput.in");
ofstream out ("lgput.out");
int main()
{
    long long n,p,r=1,r2;
    in>>n>>p;
    r2=n*n;
    if (p%2==0)
    {p=p/2;
    while (p>0)
    {
        r=r*r2;
        p--;
    }}
    else
    {
        while (p>0)
        {
            r=r*n;
            p--;
        }
    }
    out<<r%1999999973;
    return 0;
}