Cod sursa(job #2369726)
Utilizator | Data | 6 martie 2019 09:00:35 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g ("lgput.out");
long long a, n, p;
int main ()
{
f >> a >> n;
p=1;
while (n)
{
if (n%2)
{
p=(p*a)%1999999973;
n--;
}
else
{
a=(a*a)%1999999973;
n/=2;
}
}
g << p ;
return 0;
}