Cod sursa(job #2571612)
Utilizator | Data | 5 martie 2020 08:51:08 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 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 n, ll p)
{
ll s = 1;
while (p)
{
if (p % 2) s = (s * n) % MOD;
n = (n * n) % MOD;
p /= 2;
}
return s;
}
int main()
{
ll n, p;
fin >> n >> p;
fout << lgput(n, p);
}