Cod sursa(job #1923232)
| Utilizator | Data | 10 martie 2017 21:35:33 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
const long long NR_MOD=1999999973;
int main()
{
long long nr,put;
fin>>nr>>put;
long long auxput=put,solutie=1,auxnr=nr;
while(auxput>0)
{
if(auxput%2==1)
{
solutie=(solutie*auxnr)%NR_MOD;
}
auxput/=2;
auxnr=(auxnr*auxnr)%NR_MOD;
}
fout<<solutie;
return 0;
}
