Cod sursa(job #2045926)
| Utilizator | Data | 23 octombrie 2017 08:40:38 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream in("modulo.in");
ofstream out("modulo.out");
#define MAX 1999999973
long power(long x,long power,long c)
{
long res = 1;
while(power > 0)
{
if(power & 1)
res = (res*x)%c;
power = power >> 1;
x = (x*x) % c;
}
return res;
}
int main()
{
long a,b,c;
in >> a >> b >> c;
out << power(a,b,c);
return 0;
}
