Cod sursa(job #2761844)
Utilizator | Data | 4 iulie 2021 12:31:24 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
ifstream in ("lgput.in");
ofstream out ("lgput.out");
int main()
{
long long n, p;
in >> n >> p;
int r = 1;
while(p)
{
if(p % 2 == 1)
r = r * n % 1999999973;
n = n * n % 1999999973;
p /= 2;
}
out << r;
}