比赛 |
20111108 |
评测结果 |
AAAAATTTTT |
题目名称 |
分裂 |
最终得分 |
50 |
用户昵称 |
Des. |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2011-11-08 11:15:05 |
显示代码纯文本
program mushroom;
uses math;
type arr=array[0..1000]of longint;
var a,b:array[1..10000]of string;
t,k,m,n,i,j:longint;
ans:string;
function print(c:arr):string;
var t,k:longint;
s:string;
begin
s:='';
for t:=1 to c[0] do
s:=chr(ord('0')+c[t])+s;
exit(s);
end;
function add(s1,s2:string):string;
var a,b,c:arr;
t,k,m,n,i,j:longint;
begin
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
fillchar(c,sizeof(c),0);
a[0]:=length(s1);
b[0]:=length(s2);
m:=max(a[0],b[0]);
for t:=1 to a[0] do
a[t]:=ord(s1[a[0]-t+1])-ord('0');
for t:=1 to b[0] do
b[t]:=ord(s2[b[0]-t+1])-ord('0');
for t:=1 to m do
c[t]:=a[t]+b[t];
for t:=1 to m do
begin
c[t+1]:=c[t+1]+c[t] div 10;
c[t]:=c[t] mod 10;
end;
if c[m+1]>0 then c[0]:=m+1 else c[0]:=m;
exit(print(c));
end;
begin
assign(input,'mushroom.in');
reset(input);
assign(output,'mushroom.out');
rewrite(output);
readln(n);
for t:=1 to n do
begin
a[t]:='0';
b[t]:='0';
end;
a[2]:='1';
for t:=1 to n-1 do
for k:=1 to t+2 do
if odd(t) and odd(k) then
begin
if k=1 then
b[k]:=a[2]
else if k=t+2 then
b[k]:=a[t+1]
else b[k]:=add(a[k-1],a[k+1]);
end
else if (t and 1=0)and(k and 1=0) then
begin
if k=1 then
a[k]:=b[2]
else if k=t+2 then
a[k]:=b[t+1]
else a[k]:=add(b[k-1],b[k+1]);
end;
ans:='0';
for t:=1 to n+1 do
if odd(n) then
ans:=add(ans,a[t])
else ans:=add(ans,b[t]);
writeln(ans);
close(output);
end.