Pagini recente » Cod sursa (job #1903466) | Cod sursa (job #417472) | Cod sursa (job #1357753) | Cod sursa (job #670403) | Cod sursa (job #1318865)
/*
* =====================================================================================
*
* 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>
#include <fstream>
#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 = (result * x) % LARGE_NUM;
x = (x * x) % LARGE_NUM;
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;
}