Cod sursa(job #544939)
| Utilizator | Data | 2 martie 2011 14:34:54 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 kb |
#include <fstream>
#include <cstdlib>
#define MODULO 1999999973
using namespace std;
inline int _pow( int x, int n )
{
int r=1;
for( ; n; n>>=1 )
{
if( n&1 )
{
r=(1LL*r*x)%MODULO;
--n;
}
x=(1LL*x*x)%MODULO;
}
return r;
}
int main( void )
{
int x, n;
ifstream in( "lgput.in" );
in>>x>>n;
ofstream out( "lgput.out" );
out<<_pow( x, n )<<'\n';
return EXIT_SUCCESS;
}