Cod sursa(job #2366335)
Utilizator | Data | 4 martie 2019 19:37:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.29 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p,nr=1;
int main()
{
f>>n>>p;
while(p)
{
if(p%2){p--;nr=(nr*n)%1999999973;}
else{p/=2;n=(n*n)%1999999973;}
}
g<<nr<<'\n';
return 0;
}