Cod sursa(job #626596)
Utilizator | Data | 27 octombrie 2011 19:01:53 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include<fstream>
using namespace std;
long n,s,p;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
f>>n>>p;
s=1;
while(p)
if(p%2==0)
{
n=(n*n)%1999999973;
p=p/2;
}
else
{
s=(s*n)%1999999973;
n=(n*n)%1999999973;
p=p/2;
}
g<<s;
return 0;
}