Cod sursa(job #2148066)

Utilizator rares404AlShaytan - Balasescu Rares rares404 Data 1 martie 2018 15:13:01
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.41 kb
#include <cstdio>
#define mod 1999999973
using namespace std;

int main()
{
    freopen("lgput.in","r",stdin);
    freopen("lgput.out","w",stdout);
    long long n ,p ,x ;
    scanf("%lli%lli",&n,&p) ;
    x = n ;
    long long rez = 1 ;
    while (p){
        if (p % 2 == 1)
           rez = rez * x % mod ;
        x = x * x % mod ;
        p /= 2 ;
    }
    printf("%lli",rez) ;
    return 0;
}