Cod sursa(job #146670)
Utilizator | Data | 1 martie 2008 23:25:24 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include<fstream.h>
#define rest 1999999973
ifstream f("lgput.in");
ofstream g("lgput.out");
long long res, n, p;
int main()
{
f>>n>>p;
res=1;
while(n){
if( n&1 ){
res=(res*p)%rest;
n--;
}
p=(p*p)%rest;
n>>=1;
}
g<<res;
g.close();
return 0;
}