Cod sursa(job #3136559)
| Utilizator | Data | 6 iunie 2023 22:36:20 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
unsigned long long rec(unsigned long long n, unsigned long long p)
{
if (p == 0)
return 1;
if (p%2 == 0)
return rec((n*n)%1999999973, p/2);
return (n*rec(n, p-1))%1999999973;
}
int main()
{
unsigned long long n, p;
fin >> n >> p;
fout << rec(n, p);
return 0;
}
