Cod sursa(job #3215820)
Utilizator | Data | 15 martie 2024 13:12:30 | |
---|---|---|---|
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
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int LogExpo(int n, int p)
{
int Rez = 1;
while (p > 0)
{
if (p % 2 == 1)
Rez = 1LL * Rez * n % MOD;
n = 1LL * n * n % MOD;
p /= 2;
}
return Rez;
}
int main()
{
int n, p;
fin >> n >> p;
fout << LogExpo(n, p);
return 0;
}