快速幂水过,贴一下模版。
const mo=;
var x,y,n,m:int64;
function power(num,times:int64):int64;
var temp:int64;
begin
if times= then exit(num);
temp:=power(num,times>>);
power:=(temp*temp) mod mo;
if times and = then power:=(power*num) mod mo;
end;
procedure main;
begin
readln(m,n);
x:=power(m,n);
y:=power(m-,n-);
y:=(y*m) mod mo;
writeln((x-y+mo) mod mo);
end;
begin
main;
end.