Cod sursa(job #1138718)
Utilizator | Data | 10 martie 2014 15:01:04 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
#define modulo 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long x, n, nr=1;
int main()
{
f>>x>>n;
while (n!=0)
{
if (n%2==1) {
nr=(nr%modulo)*(x%modulo);
nr%=modulo;
}
x=(x%modulo)*(x%modulo);
n=n/2;
}
g<<nr;
return 0;
}