Cod sursa(job #1624266)
Utilizator | Data | 2 martie 2016 09:49:17 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include<fstream>
#include<iostream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
unsigned long long p,n,x=1;
int main()
{
f>>n>>p;
while (p>0)
{ if (p%2==1)
{ x=(x*n)%1999999973;
p--;
}
p=p/2;
n=(n*n)%1999999973;
}
g<<x;
return 0;
}