Cod sursa(job #2976920)
| Utilizator | Data | 10 februarie 2023 12:57:00 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
void put(long long &a, long long &b)
{
long long k = a, l = b;
while(b != 1)
{
a = ((a % 1999999973) * (a % 1999999973)) % 1999999973;
b /= 2;
}
if (l % 2 == 1)
a = (a * k) % 1999999973;
}
int main()
{
long long a, b;
fin>>a>>b;
put(a, b);
fout<<a;
return 0;
}