Cod sursa(job #2370789)
Utilizator | Data | 6 martie 2019 13:44:00 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
using namespace std;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,nlaputere,rez,p,modulo=1999999973;
f>>n>>p;
nlaputere=n;
rez=1;
while(p)
{
if(p%2==1)
{
rez=(rez*nlaputere)%modulo;
}
p=p/2;
nlaputere=(nlaputere*nlaputere)%modulo;
}
g<<rez;
f.close();
g.close();
return 0;
}