HDU 6085 bitset
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
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?
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.
5 5 5
1 2 3 4 5
1 2 3 4 5
0 1 2 3 4
0
0
0
1
#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的更多相关文章
- HDU 6085 - Rikka with Candies | 2017 Multi-University Training Contest 5
看了标程的压位,才知道压位也能很容易写- - /* HDU 6085 - Rikka with Candies [ 压位 ] | 2017 Multi-University Training Cont ...
- HDU 6085 Rikka with Candies(bitset)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6085 [题目大意] 给出一个数组a一个数组b,以及询问数组c, 问对于每个c有多少对a%b=c,答 ...
- 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 ...
- Bipartite Graph hdu 5313 bitset 并查集 二分图
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5313 题意: 给出n个顶点,m条边,问最多添加多少条边使之构成一个完全二分图 存储结构: bitset ...
- HDU 5313 bitset优化背包
题目大意: 添加尽可能少的边,最后使图形成二分图 一开始将图区分成一个个联通分量,根据二分图染色,计算出每个联通分量的黑色点和白色点的个数 希望添加的边最少,那么合并的时候,希望黑白块尽可能平均,这无 ...
- hdu 2051 Bitset (java)
问题: 之前做过类似题,但这次仍然不能解决相关问题. 字符串倒过来输:StringBuffer str=new StringBuffer(s); s=str.reverse().toString() ...
- HDU 2051 Bitset
http://acm.hdu.edu.cn/showproblem.php?pid=2051 Problem Description Give you a number on base ten,you ...
- 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 ...
- hdu 6085 Rikka with Candies (set计数)
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...
随机推荐
- MiZ702学习笔记8——让MiZ702变身PC的方法
首先你需要一个安装好的linux系统,这里我用的是Ubuntu的虚拟机.VMWare的话,选择较高版本的成功率会高些(当然根据自己电脑的配置进行选择). 打开Ubuntu的虚拟机,找到一个叫做Disk ...
- [Deep-Learning-with-Python] Keras高级概念
Keras API 目前为止,介绍的神经网络模型都是通过Sequential模型来实现的.Sequential模型假设神经网络模型只有一个输入一个输出,而且模型的网络层是线性堆叠在一起的. 这是一个经 ...
- JS计算混合字符串长度
用的是正则表达式 var str = ”坦克是tank的音译”; var len = str.match(/[^ -~]/g) == null ? str.length : str.length + ...
- 命令行启用IIS Express
我们在调试WEB程序的时候可以把本地web程序挂载到本地IIS,然后访问程序,通过附加进程的方式(w3wp)来调试程序(个人非常喜欢的一种调试方式),还有一种比较传统的方式就是通过VS自带的F5来执行 ...
- Jmeter(二十二)_脚本上传Gitlab
Docker部署接口自动化持续集成环境第四步,代码上传到远程仓库! 接上文:Ubuntu部署jmeter与ant Gitlab在容器中部署好了之后,本地直接打开.我们可以在里面创建项目,上传脚本. 新 ...
- python3解析网页经过base64编码后的图片
有时候我们打开网页看到的图片不是普通的url,例如:www.baidu.com/static/2.jpg,而是经过base64方式加密过的路径:例如:data:img/jpg;base64,/9j/4 ...
- 测试开发:Python+Django实现接口测试工具
Python+Django接口自动化 引言: 最近被几个公司实习生整自闭了,没有基础,想学自动化又不知道怎么去学,没有方向没有头绪,说白了其实就是学习过程中没有成就感,所以学不下去.出于各种花里胡哨的 ...
- CEPH LIO iSCSI Gateway
参考文档: Ceph Block Device:http://docs.ceph.com/docs/master/rbd/ CEPH ISCSI GATEWAY:http://docs.ceph.co ...
- C++ string 类详解
字符串是存储在内存的连续字节中的一系列字符.C++ 处理字符串的方式有两种,一种来自 C 语言,常被称为 C-风格字符串,另一种是基于 string 类库的字符串处理方式.C 风格字符串的处理可以参考 ...
- imagick用法!
https://coderwall.com/p/9hj97w sudo apt-get install imagemagick sudo apt-get install php5-imagick su ...