Cod sursa(job #1396852)
Utilizator | Dragan Andrei AndreiD31 | Data | 23 martie 2015 08:42:53 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
long long p,a,n,t,prod=1,i;
int main()
{ifstream f("lgput.in");
ofstream g("lgput.out");
f>>n>>p;
t=n;
while(p>0)
{if(p%2==1){prod=(prod*t)%1999999973;p--;}
else {t=(t*t)%1999999973;p=p/2;}
}
//prod=(prod*t)%1999999973;
g<<prod<<" ";
return 0;
}