Cod sursa(job #1378212)
| Utilizator | Data | 6 martie 2015 11:01:02 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream is("lgput.in");
ofstream os("lgput.out");
const int MOD = 1999999973;
long long Pow( int a, int b );
long long n, p;
int main()
{
is >> n >> p;
os << Pow(n, p);
is.close();
os.close();
return 0;
}
long long Pow( int a, int b )
{
if ( b == 1 )
return a;
if ( b == 0 )
return 1;
long long aux = Pow( a, b / 2 );
aux = ( 1LL * aux * aux ) % MOD;
if ( b & 1 )
aux *= a;
aux %= MOD;
return aux;
}
