Cod sursa(job #2202271)

Utilizator AtanaseTeodorAtanase Alexandru-Teodor AtanaseTeodor Data 8 mai 2018 10:55:27
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.38 kb
#include <bits/stdc++.h>
#define Mod 1999999973

using namespace std;

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

int Putere(int a,int n)
{
    int p=1;
    while(n>0)
    {
        if(n%2==1) p=1LL*p*a%Mod;
        a=1LL*a*a%Mod;
        n/=2;
    }
    return p;
}

int main()
{
    int n,m;
    fin>>n>>m;
    fout<<Putere(n,m);
    return 0;
}