Cod sursa(job #1010257)
Utilizator | Data | 14 octombrie 2013 17:02:55 | |
---|---|---|---|
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 a, b, r=1;
int main()
{
fin>>a>>b;
while (b)
{
if (b%2==0)
{
a=(a*a)%1999999973;
b/=2;
}
else
{
b--;
r=(r*a)%1999999973;
}
}
fout<<r%1999999973;
return 0;
}