Cod sursa(job #2573360)
Utilizator | Data | 5 martie 2020 17:17:47 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll n, p;
const int MOD=1999999973;
ll lgput(ll n, ll p)
{
ll a=1;
while(p>0)
{
if(p&1)
{
a=(a*n)%MOD;
p--;
}
n=(n*n)%MOD;
p>>=1;
}
return a;
}
int main()
{
fin >> n >> p;
fout << lgput(n, p);
return 0;
}