2017多校联合第五场1001/hdu6085Rikka with Candies(bitset)
来源:互联网 发布:seafile数据是否加密 编辑:程序博客网 时间:2024/06/07 21:56
Rikka with Candies
Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1389 Accepted Submission(s): 606
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 aren children and m kinds of candies. The i th child has Ai dollars and the unit price of the i th 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 has10 dollars 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 hasq 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 i th child’s favorite candy is the j th kind, he will take k dollars home.
To reduce the difficulty, Rikka just need to calculate the answer modulo2 .
But It is still too difficult for Rikka. Can you help her?
There are
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
Now Yuta has
To reduce the difficulty, Rikka just need to calculate the answer modulo
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 numbersn,m,q(1≤n,m,q≤50000) .
The second line containsn numbers Ai(1≤Ai≤50000) and the third line contains m numbers Bi(1≤Bi≤50000) .
Then the fourth line containsq numbers ki(0≤ki<maxBi) , which describes the queries.
It is guaranteed thatAi≠Aj,Bi≠Bj for all i≠j .
For each testcase, the first line contains three numbers
The second line contains
Then the fourth line contains
It is guaranteed that
Output
For each query, print a single line with a single 01 digit -- the answer.
Sample Input
15 5 51 2 3 4 51 2 3 4 50 1 2 3 4
Sample Output
00001
Source
2017 Multi-University Training Contest - Team 5
Recommend
liuyiding | We have carefully selected several similar problems for you: 6107 6106 6105 6104 6103
题解:
#include <iostream>#include <algorithm>#include <cstdio>#include <cmath>#include <cstring>#include <string>#include <string.h>#include <map>#include <set>#include <queue>#include <deque>#include <list>#include <bitset>#include <stack>#include <stdlib.h>#define lowbit(x) (x&-x)#define e exp(1.0)//ios::sync_with_stdio(false);// auto start = clock();// cout << (clock() - start) / (double)CLOCKS_PER_SEC;typedef long long ll;typedef long long LL;using namespace std;int read(){ int res = 0, ch, flag = 0; if((ch = getchar()) == '-') //判断正负 flag = 1; else if(ch >= '0' && ch <= '9') //得到完整的数 res = ch - '0'; while((ch = getchar()) >= '0' && ch <= '9' ) res = res * 10 + ch - '0'; return flag ? -res : res;}const int maxn=50000+10;bitset<maxn>a,b,ans;bitset<maxn>bb;//b的倍数,bb[i]=1:有奇数个y满足i%b[y]==0void solve(int maxk){ bb.reset(); ans.reset(); for(int i=maxk;i>=0;--i)//枚举k { ans[i]=(bb&(a>>i)).count()&1; if(b[i])//枚举b[i]的倍数 for(int j=0;j<maxn;j+=i) bb.flip(j); }}int main(){ ios::sync_with_stdio(false); int T; scanf("%d",&T);//cin>>T; int n,m,q; while(T--) { scanf("%d%d%d",&n,&m,&q);//cin>>n>>m>>q; a.reset(); b.reset(); int maxk=0; for(int i=0;i<n;i++) { int x; scanf("%d",&x);//cin>>x; a.set(x); } for(int i=0;i<m;i++) { int x; scanf("%d",&x);//cin>>x; b.set(x); maxk=max(maxk,x); } solve(maxk); while(q--) { int x; scanf("%d",&x);//cin>>x; if(ans[x])puts("1");//cout<<"1"<<endl; else puts("0");//cout<<"0"<<endl; } } return 0;}
阅读全文
0 0
- 2017多校联合第五场1001/hdu6085Rikka with Candies(bitset)
- HDU 6085 Rikka with Candies(2017多校第五场)bitset枚举
- HDU6085Rikka with Candies
- 2017多校联合第五场1011/hdu6095Rikka with Competition(排序)
- 2017多校联合第五场1006/hdu6090Rikka with Graph(思维公式)
- HDU 6085 Rikka with Candies (bitset)
- HDU 6085 Rikka with Candies(bitset)
- HDU 6085 Rikka with Candies (bitset)
- 2013多校联合训练第五场
- 2014多校联合-第五场
- HDOJ多校联合第五场
- 多校联合训练第五场总结
- Hdu6085 Rikka with Candies(2017多校第5场)
- Rikka with Candies(bitset操作)
- 2017多校五 1001题 hdu 6085 Rikka with Candies 位运算 bitset
- HDU 6085 Rikka with Candies (bitset, 2017 Multi-Univ Training Contest 5)
- 【多校训练】hdu 6085 Rikka with Candies bitset
- hdu 6085 Rikka with Candies(bitset容器)
- javaseday16(基本数据类型的包装 | 集合的基本方法)
- mongodb输错命令后不能删除问题
- xshell连接virtual box中的虚拟机
- 三目运算符.A>B?A:B
- [AOP系列]Autofac+Castle实现AOP事务
- 2017多校联合第五场1001/hdu6085Rikka with Candies(bitset)
- [第六季]12.Javascript事件处理机制(一)
- 闭包浅析
- Docker化应用的坑
- 【JavaScript语言精粹】读书笔记(二)——对象
- 彻底清除Linux centos minerd木马 wnTKYg木马
- Unity3D Shader(8)——Vertex Shader(漫反射)
- hdu 6103 -Kirinriki
- 2016 ACM青岛区域赛题解