Cod sursa(job #2290123)
Utilizator | Lucian Trepteanu LucianT | Data | 25 noiembrie 2018 19:54:36 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <fstream>
using namespace std;
const int MOD=1999999973;
long long n,p;
long long fastPow(long long a,long long b){
long long res=1;
while(b>0){
if(b&1)
res=(res*a)%MOD;
a=(a*a)%MOD;
b/=2;
}
return res;
}
int main(){
ifstream cin("lgput.in");
ofstream cout("lgput.out");
cin>>n>>p;
cout<<fastPow(n,p);
return 0;
}