Cod sursa(job #2841045)
Utilizator | Data | 29 ianuarie 2022 11:12:59 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const long long mod = 1999999973;
long long n,p,k,s;
int main()
{
fin>>n>>p;
s=1;
k=n;
while (p!=0)
{
if((p % 2) == 1)
{
s=(s*k) % mod;
}
p=p/2;
k=(k*k) %mod;
}
fout<<s;
return 0;
}