Cod sursa(job #838839)
Utilizator | Data | 20 decembrie 2012 18:35:39 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include<fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p,k;
int main()
{
f>>n>>p;
k=1;
while(p!=0)
{
if(p%2==1)
k=(k*n)%1999999973;
n=n*n%1999999973;
p=p/2;
}
g<<k<<" ";
return 0;
}