为什么……
[codep]
var b,p,m,s,t:longint; begin read(b,p,m); write(b,'^',p,' mod ',m,'='); s:=1;t:=b; while p>0 do begin if p mod 2=1 then s:=s*t mod m; p:= p div 2; t:=t*t mod m; end; write(s); end. [/codep]