Программа должна считать количество способов уложить n одинаковых костей в футляр размером 2n, при этом кости не должны накладываться друг на друга.Во входном файле(input.in) n (от 0 до 30), в выходном — число способов -Delphi(Делфи)

program classification;
 
{$APPTYPE CONSOLE}
 
uses
  SysUtils;
 
var
  bin,bout:text;
   b,a:int64;
  n0,n1,n3:int64;
 
begin
assign(bin, 'classification.in');reset(bin);
assign(bout,'classification.out');rewrite(bout);
 
readln(bin, b);
n0:=0;n1:=0;n3:=0;
 
while not eof(bin) do
begin
read(bin,a);
if a=0 then inc(n0)
else if a=1 then inc(n1)
else if a=3 then inc(n3);
dec(b);
if b=0 then
writeln(bout, n3,' ',n1,' ',n0);
end;
close(bin);close(bout);
end.

Leave a Comment

4 + 1 =