Cod sursa(job #2468410)
| Utilizator | Data | 5 octombrie 2019 15:15:36 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.54 kb |
#include <bits/stdc++.h>
#define ll long long
#define uns unsigned
#define newline '\n'
using namespace std;
///******************
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const uns ll MOD(1999999973);
ll res = 1;
long pow_log(long n,long p)
{
int r = 1;
while (p)
{
if (p % 2)
res = (1LL * res * n) % MOD;
n = (n * n) % MOD;
p /= 2;
}
return res;
}
int main()
{
ll n, p;
fin >> n >> p;
fout << pow_log(n, p);
return EXIT_SUCCESS;
}
