Cod sursa(job #3121551)
Utilizator | Data | 14 aprilie 2023 00:38:35 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int main() {
unsigned int n, p;
fin >> n >> p;
unsigned int pow = 1;
while(p){
if(p & 1)
pow = (pow * n) % MOD;
n = (n * n) % MOD;
p >>= 1;
}
fout << pow << '\n';
fin.close();
fout.close();
return 0;
}