Cod sursa(job #1972808)
Utilizator | Data | 23 aprilie 2017 19:00:15 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p,prod=1,t;
int main()
{
f>>n>>p;
if(p==0)g<<1;
else
{
t=n;
while(p!=1)
{
if(p%2==1){prod=(prod*t)%1999999973;p--;}
else {t=(t%1999999973*t%1999999973)%1999999973;p=p/2;}
}
g<<(prod*t)%1999999973;
}
return 0;
}