Cod sursa(job #1917604)
Utilizator | Data | 9 martie 2017 12:37:21 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n,sol,p;
long long modulo;
int main()
{
fin>>n>>p;
sol=1;
modulo=1999999973;
while(p>=1){
if(p%2!=0)
sol=(sol*n)%modulo;
n=(n*n)%modulo;
p=p/2;
}
fout<<sol;
return 0;
}