Cod sursa(job #2575424)
Utilizator | Data | 6 martie 2020 13:28:14 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <bits/stdc++.h>
using namespace std;
const long int MD = 1999999973;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int lg(int n, int p)
{
int rez = 1;
while (p)
{
if (p & 1)
rez = (1ll * rez * n) % MD;
n = (1ll * n * n) % MD;
p /= 2;
}
return rez;
}
int main()
{
int n, p;
fin >> n >> p;
fout << lg(n, p);
}