Rikka with Candies

Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1452    Accepted Submission(s): 634

Problem Description
As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:

There are n children and m kinds of candies. The ith child has Ai dollars and the unit price of the ith kind of candy is Bi. The amount of each kind is infinity.

Each child has his favorite candy, so he will buy this kind of candies as much as possible and will not buy any candies of other kinds. For example, if this child has 10dollars and the unit price of his favorite candy is 4 dollars, then he will buy two candies and go home with 2 dollars left.

Now Yuta has q queries, each of them gives a number k. For each query, Yuta wants to know the number of the pairs (i,j)(1≤i≤n,1≤j≤m) which satisfies if the ith child’s favorite candy is the jth kind, he will take k dollars home.

To reduce the difficulty, Rikka just need to calculate the answer modulo 2.

But It is still too difficult for Rikka. Can you help her?

 
Input
The first line contains a number t(1≤t≤5), the number of the testcases.

For each testcase, the first line contains three numbers n,m,q(1≤n,m,q≤50000).

The second line contains n numbers Ai(1≤Ai≤50000) and the third line contains m numbers Bi(1≤Bi≤50000).

Then the fourth line contains q numbers ki(0≤ki<maxBi) , which describes the queries.

It is guaranteed that Ai≠Aj,Bi≠Bj for all i≠j.

 
Output
For each query, print a single line with a single 01 digit -- the answer.
 
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
 
Source
 
 #pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<bitset>
#include<time.h>
using namespace std;
int t;
int n,m,q;
bitset<> a,b,ans,exm;
int main(){
scanf("%d",&t);
for(int i=;i<=t;i++){
scanf("%d %d %d",&n,&m,&q);
a.reset();
b.reset();
int maxn=;
int x;
for(int j=; j<n;j++){
scanf("%d",&x);
a.set(x);
}
for(int j=;j<m;j++){
scanf("%d",&x);
b.set(x);
maxn=max(maxn,x);
}
exm.reset();
ans.reset();
for(int j=maxn;j>=;j--){
ans[j]=(exm&(a>>j)).count()&;//ans[j]:(a-j)%b==0的个数的奇偶性
if(b[j]){
for(int k=;k<=;k+=j)
exm.flip(k);
}
}
for(int j=;j<=q;j++){
scanf("%d",&x);
printf("%c\n",ans[x]?'':'');
}
}
return ;
}
 

HDU 6085 bitset的更多相关文章

  1. HDU 6085 - Rikka with Candies | 2017 Multi-University Training Contest 5

    看了标程的压位,才知道压位也能很容易写- - /* HDU 6085 - Rikka with Candies [ 压位 ] | 2017 Multi-University Training Cont ...

  2. HDU 6085 Rikka with Candies(bitset)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6085 [题目大意] 给出一个数组a一个数组b,以及询问数组c, 问对于每个c有多少对a%b=c,答 ...

  3. 2017多校第5场 HDU 6085 Rikka with Candies bitset

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6085 题意:存在两个长度为n,m的数组A,B.有q个询问,每个询问有一个数字k,可以得到Ai%Bj=k ...

  4. Bipartite Graph hdu 5313 bitset 并查集 二分图

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5313 题意: 给出n个顶点,m条边,问最多添加多少条边使之构成一个完全二分图 存储结构: bitset   ...

  5. HDU 5313 bitset优化背包

    题目大意: 添加尽可能少的边,最后使图形成二分图 一开始将图区分成一个个联通分量,根据二分图染色,计算出每个联通分量的黑色点和白色点的个数 希望添加的边最少,那么合并的时候,希望黑白块尽可能平均,这无 ...

  6. hdu 2051 Bitset (java)

    问题: 之前做过类似题,但这次仍然不能解决相关问题. 字符串倒过来输:StringBuffer str=new StringBuffer(s); s=str.reverse().toString() ...

  7. HDU 2051 Bitset

    http://acm.hdu.edu.cn/showproblem.php?pid=2051 Problem Description Give you a number on base ten,you ...

  8. 2017ACM暑期多校联合训练 - Team 5 1001 HDU 6085 Rikka with Candies (模拟)

    题目链接 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, s ...

  9. hdu 6085 Rikka with Candies (set计数)

    Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...

随机推荐

  1. 论FPGA建模,与面向对象编程的相似性

    很久没有写FPGA方面的博客了,因为最近一直在弄一个绘图的上位机. 我觉得自己建模思想还不错,但是面向对象思维总是晕的.突然有一天发现,两者居然有这么对共同之处,完全可以相互启发啊.就简单聊下. 1. ...

  2. centos 7 搭建开源堡垒机 Teleport 遇到的问题解决

    不得不说 centos7 的环境版本就是高,没有再出现6.5下那些依赖组件的版本支持过低的错误了,所以说现在个人用户还是推荐用7,企业生产环境的话,可能6.5适合一些,至少2年前是这样. 安装过程:  ...

  3. pycharm自动生成头文件注释

    1.在file->settings->file and code templates->python script即可自定制pycharm创建文件自动生成的头文件注释信息 2.创建p ...

  4. 如何在百度云虚拟机中配置thinkphp5,并且url去掉index.php

    第一步:将public目录下的index.php移到和public同级目录下,[或者直接在public同级目录下新建一个index.php] 第二步:那么这个新的index.php文件的内容如下: & ...

  5. Kubernetes并发控制与数据一致性的实现原理

    在大型分布式系统中,定会存在大量并发写入的场景.在这种场景下如何进行更好的并发控制,即在多个任务同时存取数据时保证数据的一致性,成为分布式系统必须解决的问题.悲观并发控制和乐观并发控制是并发控制中采用 ...

  6. Hyperldeger Fabric踩过的坑

    给参与者颁发身份时错误 错误信息: fabric-ca request register failed with errors [[{"code":400,"messag ...

  7. PAT-1045. Favorite Color Stripe (30)-LIS

    将Eva喜欢的颜色按顺序编个优先级, 2 3 1 5 6-> 1 2 3 4 5 然后读取stripe,将Eva不喜欢的先剔除掉,剩下的颜色替换为相应的优先级 2 2 4(去掉) 1 5 5 6 ...

  8. 小组冲刺第十四天站立会议(Beta版发布)

    注: “助成”招聘网站链接:http://58.87.74.131:8080/zhucheng 欢迎大家进行评测. 一.任务看板: 二.燃尽图: 三.任务总结: 根据前期收集的用户反馈,再次对网站进行 ...

  9. OVS 精确删除流表

    OVS 精确删除流表 前言 今天看了sdnlab小姐姐的mininet教程之后,看到有一个下流表的操作,优先级没能下成功,然后回来实验一下,这个问题是解决了,不过遇到了一个小问题,ovs如何精确删除流 ...

  10. ElasticSearch 2 (11) - 节点调优(ElasticSearch性能)

    ElasticSearch 2 (11) - 节点调优(ElasticSearch性能) 摘要 一个ElasticSearch集群需要多少个节点很难用一种明确的方式回答,但是,我们可以将问题细化成一下 ...