Cod sursa(job #2717631)
Utilizator | Data | 7 martie 2021 18:37:00 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("text.in");
ofstream g("text.out");
// #define f cin
// #define g cout
long long a, b, rez = 1;
const int mod = 1999999973;
int main()
{
f >> a >> b;
a %= mod;
b %= mod - 1;
while (b)
{
if (b % 2 == 1)
{
rez = (1ll * rez * a) % mod;
}
a = (1ll * a * a) % mod;
b /= 2;
}
g << rez;
return 0;
}