Cod sursa(job #2668961)
Utilizator | Data | 5 noiembrie 2020 18:58:38 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.27 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,m,p,t,prod=1;
int main()
{f>>n>>p;
t=n;
m=1999999973;
while(p)
{
if(p%2==1){prod=(prod*t)%m;p--;}
else{t=t*t%m;p=p/2;}
}g<<prod;
return 0;
}