zoukankan      html  css  js  c++  java
  • poj2436

    位操作枚举

    View Code
    #include <iostream>
    #include
    <cstdlib>
    #include
    <cstring>
    #include
    <cstdio>
    using namespace std;

    #define maxn 1005

    int n, d, k;
    int cow[maxn];

    bool ok(int a)
    {
    int ret = 0;
    while (a)
    {
    ret
    += (a & 1);
    a
    >>= 1;
    }
    return ret == k;
    }

    int main()
    {
    //freopen("t.txt", "r", stdin);
    scanf("%d%d%d", &n, &d, &k);
    for (int i = 0; i < n; i++)
    {
    int a, b;
    scanf(
    "%d", &a);
    for (int j = 0; j < a; j++)
    {
    scanf(
    "%d", &b);
    cow[i]
    |= (1 << (b - 1));
    }
    }
    int s = (1 << k) - 1;
    int e = s << (d - k);
    int ans = 0;
    for (int i = s; i <= e; i++)
    if (ok(i))
    {
    int temp = 0;
    for (int j = 0; j < n; j++)
    if ((cow[j] & i) == cow[j])
    temp
    ++;
    ans
    = max(ans, temp);
    }
    printf(
    "%d\n", ans);
    return 0;
    }
  • 相关阅读:
    LVS DR模式的简单应用
    Linux新加硬盘如何识别 分区 持续挂载
    13周作业
    12周作业
    2次月考
    10周作业
    9周作业
    8周作业
    7周作业
    6周作业
  • 原文地址:https://www.cnblogs.com/rainydays/p/2168703.html
Copyright © 2011-2022 走看看