Cod sursa(job #2865573)
Utilizator | Data | 8 martie 2022 22:23:52 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
#define ll long long
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll LgPut(ll a, ll b)
{
ll p = 1;
while (b)
{
if (b % 2 == 1)
p = p * a % MOD;
a = a * a % MOD;
b /= 2;
}
return p;
}
int main()
{
ll a, b;
fin >> a >> b;
fout << LgPut(a, b) << "\n";
return 0;
}