Cod sursa(job #1973143)
Utilizator | Data | 24 aprilie 2017 17:27:15 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define Mod 1999999973
long long N,P,a,x;
int main()
{
long long i;
fin>>N>>P;
a=1;
x=N;
for(i = 1; i <= P; i = (i<<1))
{
if((P & i) > 0) a = (a * x) % Mod;
x = (x * x) % Mod;
}
fout<<a;
return 0;
}