ac1197.pas

来自「同济大学 Online在线题库 AC源代码合集 程序设计竞赛必看资料」· PAS 代码 · 共 32 行

PAS
32
字号
program tju1197;
const
  maxn=50;
var
  e:array[0..maxn]of int64;
  p:array[0..2,0..maxn]of int64;
  n,m,i,j,a,b,c:word;
  ch:char;
begin
  e[0]:=1;for i:=1 to maxn do e[i]:=e[i-1]*2;
  repeat
    fillchar(p,sizeof(p),0);p[0,0]:=1;
    read(n,m);
    for i:=0 to n-1 do begin
      a:=i mod 3;b:=(i+1) mod 3;c:=(i+2) mod 3;
      fillchar(p[c],sizeof(p[c]),0);
      for j:=0 to i do begin
        repeat read(ch);until ch in ['*','.'];
        case ch of
          '*':begin inc(p[b,j],p[a,j]);inc(p[b,j+1],p[a,j]);end;
          '.':inc(p[c,j+1],p[a,j]*4);
        end;
      end;
    end;
    if p[b,m]=0 then begin writeln('0/1');continue;end;
    while not odd(p[b,m]) do begin
      p[b,m]:=p[b,m] shr 1;dec(n);
    end;
    writeln(p[b,m],'/',e[n]);
  until seekeof;
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?