Cod sursa(job #2909831)
Utilizator | Data | 16 iunie 2022 09:36:44 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <bits/stdc++.h>
using namespace std;
const int MOd=1999999973;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long powlg(long long a, long long p)
{
long long val=1,x=a%MOd;
while (p>0)
{
if (p%2!=0)
val=val*x%MOd;
x=x*x%MOd;
p/=2;
}
return val;
}
int main()
{
int a,p;
fin>>a>>p;
fout<<powlg(a,p);
return 0;
}