Cod sursa(job #2668958)
Utilizator | Data | 5 noiembrie 2020 18:56:13 | |
---|---|---|---|
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 f("lgput.in");
ofstream g("lgput.out");
int main()
{
long long n, p, prod=1, t, m=1999999973;
f>>n>>p;
t=n;
while(p)
{
if(p%2==1)
{
prod=prod*t%m;
p--;
}
else t=t*t%m;
p/=2;
}
g<<prod;
return 0;
}