Cod sursa(job #2144709)
Utilizator | Data | 26 februarie 2018 21:25:58 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
#define modulo 1999999973
long long x,p,solutie=1;
int main()
{
f>>x>>p;
for (int i=1;i<=p;i<<=1)
{
if ((p&i)>0)
solutie=(solutie*x)%modulo;
x=(x*x)%modulo;
}
g<<solutie%modulo;
return 0;
}