Cod sursa(job #2561483)

Utilizator Teo_1101Mititelu Teodor Teo_1101 Data 28 februarie 2020 20:37:07
Problema Potrivirea sirurilor Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.48 kb
#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;
}