2017年10月05日普及组 比萨

这里写图片描述

分析
其实就是求组合

程序:

var
n,m,i,x,y,j:longint;
ans:int64;
s:array[0..20] of longint;
f:array[0..52] of longint;

procedure dfs(x,y:longint);
var
i:longint;
begin
    if x>n then
    begin
        for i:=1 to m do
        if f[i] and y=f[i] then exit;
        inc(ans);
        exit;
    end;
    dfs(x+1,y);
    dfs(x+1,y+s[x-1]);
end;

begin
    readln(n,m);
    s[0]:=1;
    for i:=1 to n do
    s[i]:=s[i-1]*2;
    for i:=1 to m do
    begin
        read(x);
        for j:=1 to x do
        begin
            read(y);
            f[i]:=f[i]+s[y-1];
        end;
    end;
    dfs(1,0);
    writeln(ans);
end.

原文地址:https://www.cnblogs.com/YYC-0304/p/9500041.html