Cod sursa(job #1619987)
Utilizator | Data | 28 februarie 2016 20:06:28 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
#define Mod 1999999973
using namespace std;
ifstream cin("lgput.in");
ofstream cout("lgput.out");
long long a, b, x, Ans;
int main(){
cin >> a >> b;
x = a;
Ans = 1;
for(int i = 0; (1LL << i) <= b; ++i){
if((1LL << i) & b)
Ans = (Ans * x) % Mod;
x = (x * x) % Mod;
}
cout << Ans;
return 0;
}