HDU 6085 Rikka with Candies (bitset)
来源:互联网 发布:蓝牙适配器串口软件 编辑:程序博客网 时间:2024/06/07 16:29
Rikka with Candies
HDU 6085 2017ACM暑期多校联合训练 - Team 5 1001 Rikka with Candies
题目链接
题目描述
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 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?
输入
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<iostream>#include<cstring>#include<cstdio>#include<bitset>using namespace std;int vis[50040];int output[50050];bitset<50050>tmp,ans,temp;int main(){ int t; scanf("%d",&t); while(t--) { memset(vis,0,sizeof(vis)); tmp.reset();//初始化,将所有的二进制定位0 ans.reset(); int n,m,qq,maxx=0; scanf("%d%d%d",&n,&m,&qq); int x; for(int i=1;i<=n;i++) { scanf("%d",&x); tmp.set(x);//将tmp中x处的二进制改为1 } for(int i=1;i<=m;i++) { scanf("%d",&x); maxx=max(maxx,x); vis[x]=1;//标记单价 } for(int i=maxx;i>=0;i--) { temp=ans&(tmp>>i);//tmp中的二进制向右移动i位 output[i]=temp.count()%2;//计算temp中二进制为1的个数 if(vis[i]==1) for(int j=0;j<=maxx;j+=i) ans.flip(j);//二进制取反 } while(qq--) { scanf("%d",&x); printf("%d\n",output[x]); } } 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 (bitset, 2017 Multi-Univ Training Contest 5)
- HDU 6085 Rikka with Candies(2017多校第五场)bitset枚举
- HDU 6085 Rikka with Candies
- HDU 6085 Rikka with Candies
- HDU 6085 Rikka with Candies
- hdu 6085 Rikka with Candies
- Java程序员面试中的多线程问题
- Android ActionBar完全解析,使用官方推荐的最佳导航栏(上)
- QT 信号槽用法 实例
- POJ 3264 Balanced Lineup——线段树
- Android(4):Android Studio zxing扫码
- HDU 6085 Rikka with Candies (bitset)
- 项目总结一
- MySQL的explain中的参数说明
- 第一课 Tensorflow基本概念
- Hadoop生态系统
- ECharts地图API使用实例
- iOS 调起第三方程序打开文件 ( UIDocumentInteractionController )
- XListView
- sql基本操作增删改查