var n : longint; function fun(n, fromPos, toPos : longint) : longint; var t, tot : longint; begin if n = 0 then exit(0); for t := 1 to 3 do if (t <> fromPos) and (t <> toPos) then break; tot := 0; inc(tot, fun(n - 1, fromPos, t)); inc(tot); inc(tot, fun(n - 1, t, toPos)); exit(tot); end; begin read(n); writeln(fun(n, 1, 3)); end.
输入:5
输出:1
