Cod sursa(job #1644305)
Utilizator | Data | 9 martie 2016 22:26:03 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define ULL unsigned long long
#define MOD 1999999973
ULL n, p, sol, x;
int main() {
fin >> n >> p;
sol = 1;
x = n;
while(p) {
if ( p & 1 )
sol = (sol * x) % MOD;
x = (x * x) % MOD;
p >>= 1;
}
fout << sol;
fin.close();
fout.close();
return 0;
}