Pagini recente » Cod sursa (job #698973) | Cod sursa (job #2036733) | Cod sursa (job #91346) | Cod sursa (job #346506) | Cod sursa (job #2561483)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("modulo.in");
ofstream fout("modulo.out");
int A, B, C;
int Exp( int A, int B, const int & C )
{
if( B == 0 ) return 1;
int P = Exp( A, B/2, C );
if( B % 2 == 0 ) return (1LL * P * P) % C;
else return (1LL * A * (1LL * P * P) % C ) % C;
}
void Solve()
{
fin >> A >> B >> C;
A %= C;
fout << Exp( A, B, C );
}
int main()
{
Solve();
return 0;
}