zoukankan      html  css  js  c++  java
  • HDU 3006 The Number of set

    The Number of set

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 722    Accepted Submission(s): 437


    Problem Description
    Given you n sets.All positive integers in sets are not less than 1 and not greater than m.If use these sets to combinate the new set,how many different new set you can get.The given sets can not be broken.
     
    Input
    There are several cases.For each case,the first line contains two positive integer n and m(1<=n<=100,1<=m<=14).Then the following n lines describe the n sets.These lines each contains k+1 positive integer,the first which is k,then k integers are given. The input is end by EOF.
     
    Output
    For each case,the output contain only one integer,the number of the different sets you get.
     
    Sample Input
    4 4 1 1 1 2 1 3 1 4 2 4 3 1 2 3 4 1 2 3 4
     
    Sample Output
    15 2
     
    Source
     
    Recommend
    gaojie

    //这题很神奇的算法、呵呵

    #include <iostream>
    #include <stdio.h>
    #include <string.h>
    #define Y 1<<15
    using namespace std;
    bool a[Y+1];
    int main()
    {
        int n,m,in;
        int i,k,t,tin;
        while(scanf("%d%d",&n,&m)!=EOF)
        {
            t=1<<(m+1);
            for(i=1;i<=t;i++)
              a[i]=0;
            for(i=1;i<=n;i++)
            {
               scanf("%d",&k);
               tin=0;
               while(k--)
               {
                 scanf("%d",&in);
                 tin+=1<<in;
               }
               a[tin]=1;
              for(k=1;k<=t;k++)
                if(a[k])
                 a[k|tin]=1;
            }
            k=0;
          for(i=1;i<=t;i++)
              if(a[i])
               k++;
          printf("%d\n",k);
        }
        return 0;
    }

  • 相关阅读:
    pycharm连接远程服务器(拉取版本)
    Xftp5中文文件乱码
    pycharm连接远程服务器
    Centos中使用virtualenvwrapper
    VNC连接centos图形化界面
    PIP设置镜像源
    Java实现地理坐标判断
    词袋模型和句子相似度
    词向量入门
    《深入理解 Java 虚拟机》读书笔记:类文件结构
  • 原文地址:https://www.cnblogs.com/372465774y/p/2590368.html
Copyright © 2011-2022 走看看