Cod sursa(job #2841044)
Utilizator | Data | 29 ianuarie 2022 11:11:48 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int mod = 1999999973;
int 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;
}