Cod sursa(job #2098420)
Utilizator | Data | 2 ianuarie 2018 19:49:12 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MODULE = 1999999973;
int pwr(int base, int exp){
int ans;
for(ans=1; exp; exp>>=1){
if(exp & 1)
ans = (1LL*ans*base) % MODULE;
base = (1LL*base*base) % MODULE;
}
return ans%MODULE;
}
int main(){
int n, p;
fin >> n >> p;
fout << pwr(n,p);
}