Cod sursa(job #895509)
Utilizator | Data | 27 februarie 2013 11:39:13 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long a,p;
int main()
{
f>>a>>p;
while(p!=0){
if(p%2==0){
a=a*a;
p=p/2;
}
else{
a=a*p;
p--;
}
}
g<<a%1999999973;
return 0;
}