Cod sursa(job #3029991)
Utilizator | Data | 17 martie 2023 12:49:35 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <bits/stdc++.h>
using namespace std;
//ifstream fin("file.in");
//ofstream fout("file.out");
typedef long long ll;
const ll mod = 1999999973;
ll logpow(ll x,ll y)
{
ll rez=1;
while(y>0)
{if(y%2==1)
rez = ((rez%mod)*(x%mod))%mod;
x = ((x%mod)*(x%mod))%mod;
y/=2;
}
return rez%mod;
}
int main()
{
ll n,p;
cin>>n>>p;
cout<<logpow(n,p);
}