Cod sursa(job #582057)
| Utilizator | Data | 14 aprilie 2011 20:33:18 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 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" );
ofstream out( "lgput.out" );
in>>x>>n;
out<<pow( x, n )<<'\n';
return EXIT_SUCCESS;
}
