Cod sursa(job #1509883)
Utilizator | Data | 24 octombrie 2015 13:32:49 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long n, p, prod=1;
fin>>n>>p;
while(p!=1){
if(p%2==0){
p/=2;
n*=n%1999999973;
}
else{
p--;
prod*=n%1999999973;
}
}
fout<<(prod*n)%1999999973;
return 0;
}