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 ...
随机推荐
- 使用 spring-boot-devtools 进行热部署
2019/3/5 更新: 发现热部署不生效,出现页面显示error的错误,然后在 application.properties 中注释了下面两行成功实现热部署(直接删掉也可以) #spring.dev ...
- Java 多线程之 Thread 类 和 Runnable 接口初步使用
目录 Thread 类 Thread之定义线程类 Thread之开启线程 Runnable 接口 Runnable 之定义线程类 Runnable 之开启线程 @ Thread 类 Thread 类是 ...
- 设计模式 笔记 责任链模式 chain of responsibility
//---------------------------15/04/25---------------------------- //Chain of responsibility 责任链----- ...
- Ubuntu侧边任务栏自动隐藏
设置>>Dock>>{自动隐藏Dock}选项打开
- 使用Fidder从安卓模拟器获取APP内H5游戏网址
大家都知道H5游戏其实是网页,但是有些APP或者微端不显示网址链接.这里给大家介绍介绍一种,利用Fiddler进行抓包,获取APP打开的网址的方法.有人说何必多此一举呢,直接用模拟器玩游戏就好了.的确 ...
- 教你用PS制作雨天窗户上透明水滴字
雨天窗户上透明水滴字制作方法很简单,主要利用图层样式来实现.学习后可以让你对图层样式有更好的了解,认识. 先看下完成后的效果图: 步骤1: 在Photoshop中我们新建或Ctrl+N,创建1920x ...
- PAT甲题题解-1043. Is It a Binary Search Tree (25)-二叉搜索树
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789220.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- 1092. To Buy or Not to Buy (20)-map
给出两个字符串,判断第二个字符串中的字符是否都出现在第一个中. 是,则输出Yes,以及多余的字符的个数. 否,则输出No,以及缺失的个数. #include <iostream> #inc ...
- windows 64bit 服务器下安装32位oracle database 11g 问题集
1.中文乱码 问题描述: 利用vs2008调试的时候正常,发布到IIS8.5上的时候,当查询语句中包含中文的时候会乱码,比如"select * from tb where name='小s' ...
- 软件工程课程设计——第一个Spring
开发会议框架表格: 1.我们团队Reborn针对需求功能进行热烈的讨论会议,从功能的方面分析开发,结合在一起组合为App软件,再另外思考附加的功能性娱乐项目. 2.开发过程中,以表格的形式反思开发过程 ...