Cod sursa(job #2936069)
Utilizator | Data | 7 noiembrie 2022 23:12:06 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
typedef long long ll;
ll putere(ll a, ll b)
{
ll p=1;
for(ll k=1; k<=b; k<<=1)
{
if((b&k))
p=(p*a)%mod;
a=(a*a)%mod;
}
return p;
}
ll n, p;
int main()
{
fin>>n>>p;
fin.close();
fout<<putere(n, p);
fout.close();
return 0;
}