Cod sursa(job #558235)
Utilizator | Data | 17 martie 2011 10:02:37 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
using namespace std;
ifstream intrare("lgput.in");
ofstream iesire("lgput.out");
int main()
{
long long int n,rez,px,r,x;
intrare >> x >> n;
rez = 1, px = x;
while (n)
{
r = n % 2;
if (r)
rez *= px;
rez = rez % 1999999973;
px*= px;
px = px % 1999999973;
n /= 2;
}
iesire << rez << '\n';
return 0;
}