Cod sursa(job #2167986)
Utilizator | Doroftei Victor vic_d54 | Data | 14 martie 2018 08:48:28 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
#include <algorithm>
#include <math.h>
#define MOD 1999999973
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long n,p;
long long putere(long long x,long long y)
{
long long r=1;
while(y)
{
if(y%2==1)
r=(r*x)%MOD;
x=(x*x)%MOD;
y>>=1;
}
return r;
}
int main()
{
in>>n>>p;
out<<putere(n,p);
return 0;
}