Cod sursa(job #736524)
| Utilizator | Data | 18 aprilie 2012 21:28:59 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
#include <cstdlib>
using namespace std;
const int MODULO=1999999973;
inline int pow(int x, int n)
{
int r;
for(r=1; n; n>>=1)
{
if(n&1)
r=(1LL*r*x)%MODULO;
x=(1LL*x*x)%MODULO;
}
return r;
}
int main()
{
int x, n;
ifstream in("lgput.in");
ofstream out("lgput.out");
in>>x>>n;
out<<pow(x, n)<<'\n';
return EXIT_SUCCESS;
}
