Cod sursa(job #3186923)
| Utilizator | Data | 26 decembrie 2023 16:00:26 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
#define Mod 1999999973
using namespace std;
typedef unsigned int U;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
U n, p;
U LogExpo(int n, int p)
{
U Rez = 1;
while (p > 0)
{
if (p % 2 == 1)Rez = 1LL * Rez * n % Mod;
p /= 2;
n = 1LL * n * n % Mod;
}
return Rez;
}
int main()
{
fin >> n >> p;
fout << LogExpo(n, p);
return 0;
}