Pagini recente » Istoria paginii runda/concurs_pd/clasament | Cod sursa (job #597409) | Cod sursa (job #277693) | Cod sursa (job #792999) | Cod sursa (job #1411919)
#include <iostream>
#include <fstream>
int expSquare(int x, int n)
{
if ( n < 0 ) return 1;
else if ( n == 0 ) return 1;
else if ( n == 1 ) return x;
else if ( n % 2 == 0 ) return expSquare(x*x,n/2);
else if ( n % 2 == 1 ) return x * expSquare(x*x,(n-1)/2);
}
int main( int argc, char* argv[] )
{
std::ifstream input( "lgput.in" );
std::ofstream output( "lgput.out" );
int N,P;
input >> N >> P;
output << expSquare(N,P) % 1999999973;
input.close();
output.close();
return 0;
}