Cod sursa(job #2435121)
Utilizator | Data | 3 iulie 2019 10:56:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
using namespace std;
ifstream cin("lgput.in");
ofstream cout("lgput.out");
#define M 1999999973
#define ll long long
ll n, p;
ll pow(ll x, ll n)
{
if (n == 1) return x % M;
if (n % 2) return (x % M * pow(x % M * x % M, (n - 1) / 2) % M) % M;
return pow((x % M) * (x % M), n / 2) % M;
}
int main()
{
cin >> n >> p;
cout << pow(n, p) % M;
}