f(1)=1,f(2)=1,f(n)=(A*f(n-1)+B*f(n-2)) mod 7.给定A,B和n的值,要求计算f(n)的值.typearr=array[1..2,1..2]of longint;varnow,d:arr;n:longint;procedure init;vara,b:longint;beginassign(input,'sequence.in');reset(input);assign(output,'sequence.out'

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/27 21:47:42
f(1)=1,f(2)=1,f(n)=(A*f(n-1)+B*f(n-2)) mod 7.给定A,B和n的值,要求计算f(n)的值.typearr=array[1..2,1..2]of longint;varnow,d:arr;n:longint;procedure init;vara,b:longint;beginassign(input,'sequence.in');reset(input);assign(output,'sequence.out'
xTAo0+d&ivK%$JLBiH](!T$ݿ$.U9qBJ{';ᘨcpLcP ah':_@z8@O:2]>#A zsu="! xF\pvf<0t{"T P3,KA"yf?۾(y 1B`>E,-ӦZ3GaVm \b(U)+HgS$ ΛALd7"dYB+, BEU.͙U tЉ\`ttJ r%N[]"d,3d q8xMt7A unz6zv5pL-p,YPTp$gb匿UE)I]Jy N ]sJ%:#*ŨίT(.[cיNo_ܽ<{E2%d4A(|ɛ=ZOk&

f(1)=1,f(2)=1,f(n)=(A*f(n-1)+B*f(n-2)) mod 7.给定A,B和n的值,要求计算f(n)的值.typearr=array[1..2,1..2]of longint;varnow,d:arr;n:longint;procedure init;vara,b:longint;beginassign(input,'sequence.in');reset(input);assign(output,'sequence.out'
f(1)=1,f(2)=1,f(n)=(A*f(n-1)+B*f(n-2)) mod 7.给定A,B和n的值,要求计算f(n)的值.
type
arr=array[1..2,1..2]of longint;
var
now,d:arr;
n:longint;
procedure init;
var
a,b:longint;
begin
assign(input,'sequence.in');
reset(input);
assign(output,'sequence.out');
rewrite(output);
readln(a,b,n);
now[1,1]:=a mod 7;now[1,2]:=1;
now[2,1]:=b mod 7;now[2,2]:=0;
d[1,1]:=1;d[1,2]:=1;
d[2,1]:=0;d[2,2]:=0;
end;
function cheng(a,b:arr):arr;
begin
cheng[1,1]:=(a[1,1]*b[1,1]+a[1,2]*b[2,1])mod 7;
cheng[1,2]:=(a[1,1]*b[1,2]+a[1,2]*b[2,2])mod 7;
cheng[2,1]:=(a[2,1]*b[1,1]+a[2,2]*b[2,1])mod 7;
cheng[2,2]:=(a[2,1]*b[1,2]+a[2,2]*b[2,2])mod 7;
end;
function try(now:arr;n:longint):arr;
begin
if n=1 then try:=now
else
if n and 1=1 then try:=cheng(now,try(cheng(now,now),n div 2))
else try:=try(cheng(now,now),n div 2);
end;
procedure main;
begin
n:=n-2;
now:=try(now,n);
writeln(cheng(d,now)[1,1]);
end;
begin
init;
if n

f(1)=1,f(2)=1,f(n)=(A*f(n-1)+B*f(n-2)) mod 7.给定A,B和n的值,要求计算f(n)的值.typearr=array[1..2,1..2]of longint;varnow,d:arr;n:longint;procedure init;vara,b:longint;beginassign(input,'sequence.in');reset(input);assign(output,'sequence.out'
看下面超链接,希望对您有用,一直看没人给您回答!

。。。。。