Cod sursa(job #2930351)
| Utilizator | Data | 28 octombrie 2022 10:57:36 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <fstream>
using namespace std;
#define mod 1999999973
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long a, b, aux = 1, rez = 1, putere, aux3;
fin >> a >> b;
putere = a;
while (aux<=b)
{
aux3 = (b & aux);
if (aux3 != 0)
rez*=putere;
rez %= mod;
aux <<= 1;
putere*= putere %mod;
putere %= mod;
}
fout << rez%mod;
return 0;
}
