Pagini recente » Cod sursa (job #1415015) | Cod sursa (job #1802350) | Cod sursa (job #532555) | Cod sursa (job #1545954) | Cod sursa (job #1318857)
/*
* =====================================================================================
*
* Filename: pow_infoarena.cpp
*
* Description:
*
* Version: 1.0
* Created: 01/16/2015 02:04:23 PM
* Revision: none
* Compiler: gcc/g++
*
* Author: Marius-Constantin Melemciuc
* email:
* Organization:
*
* =====================================================================================
*/
#include <iostream>
#include <cstdio>
#define LARGE_NUM 1999999973
using namespace std;
int pow2(int x, int y)
{
bool is_negative = false;
if (y < 0)
{
is_negative = true;
y = -y;
}
int result = 1;
while (y != 0)
{
if ((y & 1) == 1) // is odd
result *= x;
x = x * x;
y = y >> 1;
} /* while */
return result;
}
int main(int argc, char** argv)
{
ifstream input("lgput.in");
ofstream output("lgput.out");
int n, p;
input >> n >> p;
output << pow2(n, p) % LARGE_NUM;
return 0;
}