Cod sursa(job #2909858)
| Utilizator | Data | 16 iunie 2022 11:55:20 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
const unsigned mod = 1999999973;
unsigned n, p;
unsigned plog(unsigned b, unsigned e, unsigned modul) {
unsigned p = 1;
while (e) {
if (e & 1) p = (1ll * p * b) % modul;
b = (1ll * b * b) % modul;
e >>= 1;
}
return p;
}
int main() {
f >> n >> p;
g << plog(n, p, mod);
return 0;
}