Cod sursa(job #2587456)
Utilizator | Data | 22 martie 2020 18:14:12 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
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");
long long int n, p, x, r;
int main()
{
fin>>n>>p;
x=1;
while(p!=0)
{
r=p%2;
p=p/2;
if(r==0)
x=x*x;
else
{
x=x*x;
x=x*n;
}
}
fout<<x%1999999973;
return 0;
}