Cod sursa(job #2436099)
Utilizator | Data | 4 iulie 2019 16:11:23 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
using namespace std;
ifstream inf("lgput.in");
ofstream outf("lgput.out");
const unsigned int MOD = 1999999973;
int main() {
long long n, p, x = 1;
inf >> n >> p;
while(p > 1) {
if(p & 1) {
x = (x * n) % MOD;
}
n = (n * n) % MOD;
p >>= 1;
}
outf << (n * x) % MOD;
return 0;
}