hdu 6085 Rikka with Candies bitset
来源:互联网 发布:爱奇艺会员 淘宝没卖了 编辑:程序博客网 时间:2024/05/20 16:01
Rikka with Candies
Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 553 Accepted Submission(s): 232
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 10 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 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
#include<bits/stdc++.h>using namespace std;const int N = 5e4+100;bitset<N> a,b[2],c,d;int num[N];int n,m,q;int mx,mxm;bool vis[N];void dfs(bitset<N>&now,bitset<N> tmp,int x){ now ^= (now >> (x/2)); tmp >>= (x/2); now &= tmp; if(vis[x/2]) {b[0] ^= now;vis[x/2] = false;} x/=2; if(x%2 == 0){ dfs(now,tmp,x); }}int main(){ int T; cin >> T; while(T--){ scanf("%d %d %d",&n,&m,&q); memset(vis,false,sizeof(vis)); a.reset();//原数组 b[0].reset();//ans b[1].reset();//每次个j c.reset();//去除后面一段 mx = 0;//a数组最大值 mxm = 0;//b数组最大值 for(int i= 1;i <= n;i ++){ int now; scanf("%d",&now); mx = max(now,mx); a.set(now); } for(int i= 1; i<= m;i ++) { int now; scanf("%d",&now); mxm = max(mxm,now); vis[now] = true; } for(int i= 0;i <= mxm;i ++) c.set(i); for(int i= mxm;i >= mxm/2;i --){ c.reset(i); d = a; b[1].reset(); int nn = 0; while(nn <= mx){ b[1] ^= d; d >>= i; nn += i; } b[1] &= c; if(vis[i]) {b[0] ^= b[1];vis[i] = false;} if(i%2 == 0) dfs(b[1],c,i); } for(int i = 1;i <= q;i ++){ int now; scanf("%d",&now); printf("%d\n",b[0][now]==true?1:0); } } return 0;}
- Hdu 6085 Rikka with Candies【思维+Bitset】
- hdu 6085 Rikka with Candies bitset
- HDU 6085 Rikka with Candies 模拟bitset
- HDU 6085 Rikka with Candies (bitset)
- HDU 6085 Rikka with Candies(bitset)
- HDU 6085 Rikka with Candies (bitset)
- HDU 6085 Rikka with Candies 压位 bitset区间提取
- hdu 6085 Rikka with Candies(bitset 计数原理)
- hdu 6085 Rikka with Candies(bitset容器)
- 【多校训练】hdu 6085 Rikka with Candies bitset
- HDU 6085 Rikka with Candies(bitset操作+思路转化)
- hdu 6085 Rikka with Candies bitset优化计数
- HDU 6085 Rikka with Candies
- HDU 6085 Rikka with Candies
- HDU 6085 Rikka with Candies
- hdu 6085 Rikka with Candies
- Rikka with Candies(bitset操作)
- HDU 6085 Rikka with Candies (bitset, 2017 Multi-Univ Training Contest 5)
- springcloud(九):配置中心和消息总线(配置中心终结版)
- VMware安装Centos教程
- python 获取系统信息—psutil安装及使用
- enumerate函数使用
- memset整理小结
- hdu 6085 Rikka with Candies bitset
- android 快速新建字符资源
- 一张图看懂小程序全生态!目前总结最全的,没有之一
- 初探Spring MVC
- PX4FLOW光流模块DIY(含部分代码讲解)
- Google Authenticator 原理及Java实现
- RocketMQ——Producer篇:启动过程
- PHP安装Redis扩展的操作步骤(Windows操作系统下)
- 图片的三级缓存