Cod sursa(job #2764822)
Utilizator | Data | 22 iulie 2021 19:01:57 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <iostream>
using namespace std;
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
long long n, p, s = 1;
cin >> n >> p;
while (p)
{
if (p % 2 == 1)
s = s * n % 1999999973;
n = n * n % 1999999973;
p = p / 2;
}
cout << s;
return 0;
}