Cod sursa(job #1462761)
Utilizator | Data | 18 iulie 2015 21:52:07 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <bits/stdc++.h>
using namespace std;
int n,e;
#define P 1999999973
long long lgpow(int b, int e){
int rez=1;
for(int i=0; (1<<i)<=e; i++){
if( e & (1<<i) )
rez*=(1LL*b) % P;
b*= (1LL*b) % P;
}
return rez;
}
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>n>>e;
fout<<lgpow(n,e);
return 0;
}