Cod sursa(job #3290366)
Utilizator | Data | 30 martie 2025 15:28:10 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in ("lgput.in");
ofstream out ("lgput.out");
long long a, n, p;
const long long mod = 1999999973;
int main()
{
ios_base::sync_with_stdio (false);
cin.tie (0);
cout.tie (0);
in >> a >> n;
p = 1;
while (n)
{
if (n % 2)
p *= a, p %= mod;
a *= a;
a %= mod;
n >>= 1;
}
out << p;
}