Cod sursa(job #1009964)
Utilizator | Data | 14 octombrie 2013 00:51:58 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <fstream>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
long long b, p, r=1;
int main()
{
fin>>b>>p;
while (p)
{
if (p%2==0)
{
b=(b*b)%1999999973;
p/=2;
}
else
{
p--;
r=(r*b)%1999999973;
}
}
fout<<r%1999999973;
return 0;
}