- 文科生的悲哀
- 2012-08-13 17:58:20 @
program ss;
var all,i,j,k,n:integer;
a:array[1..10050]of integer;
procedure find(bit:integer;ch:char);
begin
if bit=n then begin all:=all+1; exit; end;
if ch='z' then find(bit+1,'s');
if ch='h' then find(bit+1,'l');
if ch='s' then begin find(bit+1,'z'); find(bit+1,'l'); end;
if ch='l' then begin find(bit+1,'s'); find(bit+1,'h'); end;
end;
begin
readln(n);
all:=0;
find(1,'z');
writeln(all);
end.
这个超时??
1 条评论
-
swm LV 10 @ 2015-08-23 11:05:53
当然超时,递归复杂度是指数级的,而且你没有取模
- 1