Cod sursa(job #2677756)
Utilizator | Data | 27 noiembrie 2020 12:58:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <bits/stdc++.h>
#define rest 1999999973
#define ll long long
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll n,p;
int main()
{
fin>>n>>p;
ll ans=1;
ll i=0;
ll put=n;
while((1LL<<i)<=p)
{
if((1LL<<i)&p)
ans=(ans*put)%rest;
put=(put*put)%rest;
i++;
}
fout<<ans;
return 0;
}