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