Cod sursa(job #3124035)
| Utilizator | Data | 26 aprilie 2023 18:18:46 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include <fstream>
using namespace std;
ifstream fin("modulo.in");
ofstream fout("modulo.out");
unsigned long long a, b;
unsigned long long int ridicare(unsigned long long term, unsigned long long putere, int mod)
{
long long sol = 1;
while (putere != 0)
{
if (putere % 2 == 1)
sol = term * sol % mod;
term = term * term % mod;
putere /= 2;
}
return sol;
}
int main()
{
fin >> a >> b;
fout << ridicare(a, b, 1999999973);
}
