Cod sursa(job #2415818)
Utilizator | Data | 26 aprilie 2019 15:31:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1999999973;
int pow(int baza, int exp){
int ans = 1;
while(exp){
if(exp % 2 == 1){
ans *= baza;
ans %= mod;
}
baza *= baza;
baza %= mod;
exp /= 2;
}
return ans;
}
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int b, e;
fin >> b >> e;
fout << pow(b, e);
return 0;
}