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 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situatio…
看了标程的压位,才知道压位也能很容易写- - /* HDU 6085 - Rikka with Candies [ 压位 ] | 2017 Multi-University Training Contest 5 题意: 给定 A[N], B[N], Q 个 k 对于每个k, 求 A[i] % B[j] == k 的 (i,j)对数 限制 N, Q <=50000 分析: 对于每个 B[i] 按其倍数分块,则对于 A[j] ∈ [x*B[i],(x+1)*B[i]) , A[j]%B[i] = A…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6085 [题目大意] 给出一个数组a一个数组b,以及询问数组c, 问对于每个c有多少对a%b=c,答案对2取模 [题解] 考虑对2取模我们发现答案等价于数字的xor,01状态可以用bitset保存, 在bitset上存a的权值数组,那么每次只要将b*i~b*(i+1)-1的数值xor到答案数组的0~b-1上去即可, 鉴于bitset没有截取区间的功能,我们手写压位, 考虑压32位之后不是32倍数的…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6085 题意:存在两个长度为n,m的数组A,B.有q个询问,每个询问有一个数字k,可以得到Ai%Bj=k的种数,求种数. 解法:打表出所有查询k,k<Bi,从最大的Bi开始枚举.如果a%b==k,那么(a-k)%b==0,考虑用bitset来加速,复杂度O(n*n/32*5),要想跑得最快需要手写bitset. #include <bits/stdc++.h> using namespace…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5313 题意: 给出n个顶点,m条边,问最多添加多少条边使之构成一个完全二分图 存储结构: bitset     [用法详情:http://blog.csdn.net/piaocoder/article/details/47177891] 用时:624ms 思路: 二分图的总边数即:n*m(假设一个有n个点,另一个有m个点) 题目是给出总共的点数为n,间接求最大的边数 想到一个小学题:给出长度为n的绳子,…
题目大意: 添加尽可能少的边,最后使图形成二分图 一开始将图区分成一个个联通分量,根据二分图染色,计算出每个联通分量的黑色点和白色点的个数 希望添加的边最少,那么合并的时候,希望黑白块尽可能平均,这无疑背包dp做,但超时了...T T 跟着题解说的bitset,学了一下,果然总共10000个点不到,那么只要用bitset上的某一位代表取到的值即可- -,好神奇..这里用的是或运算 #include <cstdio> #include <cstring> #include <i…
问题: 之前做过类似题,但这次仍然不能解决相关问题. 字符串倒过来输:StringBuffer str=new StringBuffer(s); s=str.reverse().toString() Bitset Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 15548    Accepted Submission(s): 11804…
http://acm.hdu.edu.cn/showproblem.php?pid=2051 Problem Description Give you a number on base ten,you should output it on base two.(0 < n < 1000)   Input For each case there is a postive number n on base ten, end of file.   Output For each case outpu…
题目链接 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…
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 p…