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 ...
随机推荐
- linux & windows下重启oracle
Linux:方法1 用root以ssh登录到linux,打开终端输入以下命令: cd $ORACLE_HOME #进入到oracle的安装目录 dbstart #重启服务器 lsnrctl start ...
- Scala学习(二)练习
Scala控制结构和函数&练习 1. 一个数字如果为正数,则它的signum为1:如果是负数,则signum为-1:如果为0,则signum为0:编写一个函数来计算这个值 简单逻辑判断: 测试 ...
- Appium+python自动化4-元素定位uiautomatorviewer
前言 环境搭建好了,下一步元素定位,元素定位本篇主要介绍如何使用uiautomatorviewer,通过定位到页面上的元素,然后进行相应的点击等操作. uiautomatorviewer是androi ...
- 利用matlab写一个简单的拉普拉斯变换提取图像边缘
可以证明,最简单的各向同性微分算子是拉普拉斯算子.一个二维图像函数 f(x,y) 的拉普拉斯算子定义为 其中,在 x 方向可近似为 同理,在 y 方向上可近似为 于是 我们得到满足以上三个 ...
- npm安装时一些错误
1. npm install 提示no such file or directory 缺少package.json 首先初始化, npm init -f 然后安装依赖 npm install form ...
- APP相关问题汇总
APP试用过程中,我们的APP存在不少的问题,下面是一些试用者和我们自己发现的一些问题以及一些建议. 1.APP界面有些老气,界面之间过渡僵硬 2.在试用中会出现闪退情况 3.由于我们使用的是绝对布局 ...
- BFS和DFS算法
昨晚刚昨晚华为笔试题,用到了BFS和DFS,可惜自己学艺不精,忘记了实现原理,现在借用大佬写的内容给自己做个提高 转自:https://www.jianshu.com/p/70952b51f0c8 图 ...
- C语言版本:单链表的实现(优化版本)
未优化版本:http://www.cnblogs.com/duwenxing/p/7569376.html slist.h #ifndef __SLIST_H__ #define __SLIST_H_ ...
- Scalable Object Detection using Deep Neural Networks译文
原文:https://arxiv.org/abs/1312.2249
- 第二个Sprint ------第七天、第八天、第九天、第十天,第十一天
这几天我们主要讨论界面的设计,也终于有了个初步的界面: 主界面截图