Cod sursa(job #3121553)
Utilizator | Data | 14 aprilie 2023 00:49:45 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 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 % 2)
pow = ((long long) pow * n) % MOD;
n = ((long long) n * n) % MOD;
p /= 2;
}
fout << pow << '\n';
fin.close();
fout.close();
return 0;
}