Cod sursa(job #2804055)
Utilizator | Smoc George-Marian smoc_georgemarian | Data | 20 noiembrie 2021 19:38:22 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <bits/stdc++.h>
#define int int64_t
#define double long double
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int n, p;
int const mod=1999999973;
int32_t main()
{
fin >> n >> p;
int multiplier = n;
int ans = 1;
for (int i = 0; (1<<i) <= p; i++)
{
if ( (1<<i) & p)
ans = ans * multiplier % mod;
multiplier = multiplier * multiplier % mod;
}
fout << ans;
return 0;
}