Alex decided to try his luck in TV shows. He once went to the quiz named "What's That Word?!". After perfectly answering the questions "How is a pseudonym commonly referred to in the Internet?" ("Um... a nick?"), "After…
题意:有n个可重集合,有四种操作: 1:把一个集合设置为单个元素v. 2:两个集合求并集. 3:两个集合中的元素两两求gcd,然后这些gcd形成一个集合. 4:问某个可重复集合的元素v的个数取模2之后是多少. 思路:因为集合的元素是对2取模,那么我们可以用bitset来代替可重复集合.但是,如果每个bitset来直接代表多重集的话,第三个操作会很麻烦.所以我们每个集合的bitset用来代表每个元素和每个元素约数的集合,这样某个约数为标记为1说明这个约数的倍数的和为奇数(这个约数的倍数就是这个元素…
传送门 由于只要考虑 $\mod 2$ 意义下的答案,所以我们只要维护一堆的 $01$ 容易想到用 $bitset$ 瞎搞...,发现当复杂度 $qv/32$ 是可以过的... 一开始容易想到对每个集合开一个 $bitset$ ,叫 $cnt[]$ ,维护各种值的数出现了奇数还是偶数次 因为要维护那个奇怪的 $3$ 操作,所以改成维护各种值的倍数出现了奇数还是偶数次,即 $cnt[x]$ 维护集合内所有 $x|d$ 的数 $d$ 的出现次数 那么对于操作 $3$,$x$ 的倍数和 $y$ 的倍数…
B. Pasha and Phone Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/problem/B Description Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of ex…
E. Devu and Flowers 题目连接: http://codeforces.com/contest/451/problem/E Description Devu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th box contains fi flowers. All flowers in a single box are of the same color (hen…
传送门 除了操作 \(3\) 都可以 \(bitset\) 现在要维护 \[C_i=\sum_{gcd(j,k)=i}A_jB_k\] 类比 \(FWT\),只要求出 \(A'_i=\sum_{i|d}A_d\) 就可以直接按位相乘了 求答案就是莫比乌斯反演,\(A_i=\sum_{i|d}\mu(\frac{d}{i})A'_i\) 把每个数字的 \(\mu\) 的 \(bitset\) 预处理出来,乘法就是 \(and\) 最后用 \(count\) 统计答案 # include <bits…
D. Winter is here 题目连接: http://codeforces.com/contest/839/problem/D Description Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the rest of the world is fighting for the Iron Throne,…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud D. Xenia and Dominoes Xenia likes puzzles very much. She is especially fond of the puzzles that consist of domino pieces. Look at the picture that shows one of such puzzles. A puzzle is a 3 ×…
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1. Given an array a consisting of n positive integers, find the number of its coprime subsequences.…
B. Pasha and Phone   Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits. Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a…