Cod sursa(job #1170814)
| Utilizator | Data | 14 aprilie 2014 17:17:36 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <fstream>
using namespace std;
ifstream is("lgput.in");
ofstream os("lgput.out");
#define MOD 1999999973
int n, p;
long long Pow( int x, int y );
int main()
{
is >> n >> p;
os << Pow( n, p );
is.close();
os.close();
return 0;
}
long long Pow( int x, int y )
{
if ( y == 0 ) return 1;
if ( y == 1 ) return x;
long long aux = Pow( x, y / 2 );
aux = ( aux * aux ) % MOD;
if ( y % 2 == 1 )
aux *= x;
return aux;
}
