Cod sursa(job #2873315)
Utilizator | Data | 19 martie 2022 09:31:22 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
using namespace std;
ifstream fin("moka.in");
ofstream fout("moka.out");
long long putere(long long a, long long p, int mod)
{
if (p == 0) return 1;
else
{
long long x = putere(a, p / 2, mod);
if (p % 2 == 0) return x * x % mod;
else return x * x % mod * a % mod;
}
}
int main()
{
long long a, b;
fin >> a >> b;
fout << putere(a, b, 1999999973);
}