[CSP-S2020] 动物园
作者:互联网
CSP-2020动物园
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 1000005;
typedef unsigned long long ll;
int n, m, c, K;
bool vis[64];
ll a[N];
int main() {
scanf("%d%d%d%d", &n, &m, &c, &K);
ll sum = 0;
for (int i = 1; i <= n; i++) {
ll x;
scanf("%llu", &x);
sum |= x;
// 可以做到统计在已经饲养的动物中,每一个二进制位出现的1
}
int k = K;
for (int i = 1; i <= m; i++)
{
int p,q;
scanf("%d%d", &p, &q);
if (!(sum >> p & 1) && vis[p] == false)
// sum >> p & 1 表示 在已经饲养的动物中,第p个二进制位是否为1
{
vis[p] = true;//,去重
k--;
}
}
//设能选的位数是 k,答案就是 2^k - n
if (k == 64)
{
if (n == 0) puts("18446744073709551616");//2^64超范围
}
else printf("%llu\n", (1ull << k) - n);
}
标签:int,ll,d%,动物园,vis,64,S2020,include,CSP 来源: https://www.cnblogs.com/Elgina/p/15361608.html