Cod sursa(job #3152679)
Utilizator | Data | 26 septembrie 2023 11:12:42 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.54 kb |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string np = "lgput";
ifstream f(np + ".in");
ofstream g(np + ".out");
// #define f cin
// #define g cout
ll fast_pow(ll a, ll b, const ll mod = 1999999973)
{
ll rez = 1;
for (; b; a = (1ll * a * a) % mod, b /= 2)
if (b % 2 == 1)
rez = (1ll * rez * a) % mod;
return rez;
}
int main()
{
ios_base::sync_with_stdio(false);
f.tie(nullptr);
ll a, b;
f >> a >> b;
g << fast_pow(a, b) << '\n';
return 0;
}