Cod sursa(job #3152775)
Utilizator | Data | 26 septembrie 2023 18:50:36 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
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");
long long mod = 1999999973;
int main()
{
long long n, p, rez;
fin >> n >> p;
rez = 1;
while (p != 0)
{
if(p % 2 == 1) {
rez = (rez * n);
}
n = (n * n);
p = p / 2;
}
fout << rez % mod;
return 0;
}