HDU 6085 Rikka with Candies(bitset)
来源:互联网 发布:瑞虎3轮毂数据 编辑:程序博客网 时间:2024/05/22 11:40
Description
给出两个序列
Input
第一行一整数
Output
对于每组查询,输出满足
Sample Input
1
5 5 5
1 2 3 4 5
1 2 3 4 5
0 1 2 3 4
Sample Output
0
0
0
0
1
Solution
Code
#include<cstdio>#include<bitset> #include<cstring>using namespace std;namespace fastIO { #define BUF_SIZE 100000 //fread -> read bool IOerror=0; inline char nc() { static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE; if(p1==pend) { p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin); if(pend==p1) { IOerror=1; return -1; } } return *p1++; } inline bool blank(char ch) { return ch==' '||ch=='\n'||ch=='\r'||ch=='\t'; } inline void read(int &x) { char ch; while(blank(ch=nc())); if(IOerror)return; for(x=ch-'0';(ch=nc())>='0'&&ch<='9';x=x*10+ch-'0'); } inline void readc(char &x) { char ch; while(blank(ch=nc())); if(IOerror)return; x=ch; } #undef BUF_SIZE};using namespace fastIO;#define maxn 50005bitset<maxn>A,B;int T,n,m,q,b[maxn],ans[maxn];int main(){ read(T); //scanf("%d",&T); while(T--) { read(n),read(m),read(q); //scanf("%d%d%d",&n,&m,&q); A.reset(),B.reset(); for(int i=1;i<=n;i++) { int a; read(a); //scanf("%d",&a); A.set(a); } memset(b,0,sizeof(b)); int M=0; for(int i=1;i<=m;i++) { int a; read(a); //scanf("%d",&a); b[a]=1;M=max(M,a); } for(int i=0;i<=M;i++)ans[i]=0; for(int i=M;i>=0;i--) { ans[i]=((B<<i)&A).count()&1; if(b[i]) for(int k=0;k<=M;k+=i)B.flip(k); } while(q--) { int k; read(k); //scanf("%d",&k); printf("%d\n",ans[k]); } } return 0;}
阅读全文
0 0
- HDU 6085 Rikka with Candies (bitset)
- HDU 6085 Rikka with Candies(bitset)
- HDU 6085 Rikka with Candies (bitset)
- Hdu 6085 Rikka with Candies【思维+Bitset】
- hdu 6085 Rikka with Candies bitset
- HDU 6085 Rikka with Candies 模拟bitset
- hdu 6085 Rikka with Candies(bitset容器)
- HDU 6085 Rikka with Candies(bitset操作+思路转化)
- HDU 6085 Rikka with Candies 压位 bitset区间提取
- hdu 6085 Rikka with Candies(bitset 计数原理)
- 【多校训练】hdu 6085 Rikka with Candies bitset
- hdu 6085 Rikka with Candies bitset优化计数
- HDU 6085 Rikka with Candies (bitset, 2017 Multi-Univ Training Contest 5)
- HDU 6085 Rikka with Candies(2017多校第五场)bitset枚举
- HDU 6085 Rikka with Candies
- HDU 6085 Rikka with Candies
- HDU 6085 Rikka with Candies
- hdu 6085 Rikka with Candies
- jvm内存溢出实例一
- Dmitry
- 《Java核心技术(卷一)》读书笔记——第六章:内部类
- 《neural network and deep learning》题解——ch03 其他技术(momentun,tanh)
- __str__
- HDU 6085 Rikka with Candies(bitset)
- 插入排序-算法导论学习
- Spring security的图片验证码方案一
- python 与机器学习实战(何宇健)代码下载
- stm32 内存问题
- ubuntu下jdk1.8的配置
- 迅为iTOP-4412开发板开机测试、电源、拨码开关、进不去uboot模式问题
- java web学习总结31:国际化(i18n)
- 【逻辑漏洞】基于BurpSuite的越权测试实战教程