P7076 [CSP-S2020] 动物园 题解
阅读理解题,读懂了就是sb题。
建议多模两遍样例就会做了。
我们首先要知道我们能有多少种饲料可以用,用一个变量来存所有的 二进制表示下是否在这一位上有 。
如果所有的 在这一位下都没有 。 那说明这种饲料一定不能用,也就是这一位上一定不能为 。
剩下的位上就可以是 也可以是 了,总共有 种。
结果还要减去 。
/** * author: TLE_Automation * creater: 2022.6.17 **/ #include<cmath> #include<queue> #include<cstdio> #include<bitset> #include<cstring> #include<iostream> #include<algorithm> using namespace std; typedef __int128 ull; //#define int long long const int N = 1e6 + 10; const int MAXN = 2e5 + 10; const int mod = 998244353; const int INF = 0x3f3f3f3f; inline int gcd(int a, int b) {return !b ? a : gcd(b, a % b);} inline void print(ull x) {if (x < 0) putchar('-'), x = -x; if(x > 9) print(x / 10); putchar(x % 10 + '0');} inline int ksm(int a, int b) {int base = a % mod, res = 1; while(b){if(b & 1) res = (res * base) % mod; base = (base * base) % mod, b >>= 1;}return res % mod;} inline int mul(int a, int b) {int base = a % mod, res = 0; while(b){if(b & 1) res = (res + base) % mod; base = (base + base) % mod, b >>= 1;}return res % mod;} inline char readchar() {static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;} inline ull read() {ull res = 0, f = 0; char ch = readchar(); for(; !isdigit(ch); ch = readchar()) if(ch == '-')f = 1; for(; isdigit(ch); ch = readchar()) res = (res << 1) + (res << 3) + (ch ^ '0'); return f ? -res : res;} int n, m, c, k; ull pd = 0, ans = 1, Notneed = 0; signed main() { n = read(), m = read(), c = read(), k = read(); for(int i = 1; i <= n; i++) pd |= read(); for(int i = 1; i <= m; i++) { ull p = read(); read(); if(!(pd >> p & 1)) Notneed |= 1ull << p; } for(int i = 0; i < k; i++) if(!(Notneed >> i & 1)) ans <<= 1ull; print(ans - n); return 0; }
本文作者:TLE_Automation
本文链接:https://www.cnblogs.com/tttttttle/p/16388455.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!