Cod sursa(job #3152685)
Utilizator | Tuca Elvis-Costin Elvis_Costin | Data | 26 septembrie 2023 11:30:08 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
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
const ll mod = 1e9 + 7;
ll fast_pow(ll a, ll b, ll mod)
{
ll rez = 1;
for (; b; a = (1ll * a * a) % mod, b >>= 1)
if (b & 1)
rez = (1ll * rez * a) % mod;
return rez;
}
int main()
{
ios_base::sync_with_stdio(false);
f.tie(nullptr);
int a, b;
f >> a >> b;
g << fast_pow(a, b, mod);
return 0;
}