Cod sursa(job #1368701)

Utilizator EhtRalpmetFMI Ardei Claudiu-Alexandru EhtRalpmet Data 2 martie 2015 19:31:33
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.4 kb
//#include <iostream>
#include <fstream>
#include<vector>
#include<string>
#include<algorithm>


using namespace std;
ifstream cin("lgput.in");
ofstream cout("lgput.out");

long long i,n,a,p,s;

int main(){
    cin>>n>>p;
    a=n;

    for(i=0;1<<i<=p;i++){
        if(1<<i & p){
            s=(s*a)%1999999973;
        }
        a=(a*a)%1999999973;
    }

    cout<<s;
    return 0;
}