Cod sursa(job #2137232)
Utilizator | Data | 20 februarie 2018 17:58:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <bits/stdc++.h>
using namespace std;
const int M = 1999999973;
int64_t a, b, p = 1;
int main()
{
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
fin >> a >> b;
while(b)
if(b%2 == 0){
a = (a*a)%M;
b >>= 1;
}else{
p = (p*a)%M;
--b;
}
fout << p << "\n";
return 0;
}