Pagini recente » Cod sursa (job #2184958) | Cod sursa (job #1132016) | Cod sursa (job #2271829) | Cod sursa (job #2742858) | Cod sursa (job #366420)
Cod sursa(job #366420)
/*
* File: main.cpp
* Author: virtualdemon
*
* Created on November 21, 2009, 7:53 PM
*/
#include <fstream>
#include <cstdlib>
#define Modulo 1999999973
/*
*
*/
using namespace std;
inline unsigned int power( unsigned int n, unsigned int p )
{
if( 0 == n )
return 0;
if( 1 == n || 0 == p )
return 1;
if( 1 == p )
return n;
unsigned int pow=1;
while( p )
{
if( p%2 )
{
pow*=n*pow%Modulo;
--p;
continue;
}
else n*=n%Modulo;
p>>=1;
}
return pow;
}
int main(int argc, char** argv) {
unsigned int n, p;
ifstream in("lgput.in");
in>>n>>p;
ofstream out("lgput.out");
out<<power( n, p );
return (EXIT_SUCCESS);
}