Cod sursa(job #146328)
Utilizator | Data | 1 martie 2008 15:53:17 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include<fstream>
# define cmo 1999999973
using namespace std;
long long r=1, n, p, s;
int main(){
ifstream f("lgput.in");
f>>n>>p;
f.close();
s=n;
while(p){
if((p&1)){
r=r*s;
r=r%cmo;
}
s=s*s;
s=s%cmo;
p=(p>>1);
}
ofstream g("lgput.out");
g<<r<<'\n';
return 0;
}