Cod sursa(job #1154479)
Utilizator | Data | 26 martie 2014 10:41:05 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
#define m 1999999973
#define l long long
l n,p;
l pu(l x, l n)
{
l p = 1 ;
while (n)
{
if (n %2==1)
p *= x, p%=m,n-- ;
x = x * x ; x%=m;
n/=2;
}
return p%m;
}
int main()
{
f>>n>>p;
g<<pu(n,p);
}