Cod sursa(job #1939912)
Utilizator | Data | 26 martie 2017 10:07:01 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <iostream>
#include <fstream>
#define m 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long p,xlp,x,rez;
int main()
{
fin>>x>>p;
xlp=x;
rez=1;
while(p>=1)
{
if(p%2>0)
rez=(rez*xlp)%m;
xlp=(xlp*xlp)%m;
p/=2;
}
fout<<rez<<'\n';
}