Cod sursa(job #1922497)
Utilizator | Data | 10 martie 2017 17:42:23 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long rez=1,n,p,m=1999999973;
int main()
{
fin>>n>>p;
while(p>0)
{
if(p%2==0)
{
n=(n*n)%m;
p=p/2;
}
else
{
rez=(rez*n)%m;
p--;
}
}
fout<<rez;
return 0;
}