Codeforces 460 D. Little Victor and Set】的更多相关文章

暴力+构造 If r - l ≤ 4 we can all subsets of size not greater than k. Else, if k = 1, obviously that answer is l. If k = 2, answer is 1, because xor of numbers 2x and 2x + 1 equls 1. If k ≥ 4 answer is 0 because xor of to pairs with xor 1 is 0. If k = 3,…
D Little Victor and Set 题目链接 构造的好题.表示是看了题解才会做的. 假如[l,r]长度不超过4,直接暴力就行了. 假如[l,r]长度大于等于5,那么如果k = 1,显然答案应该是l:如果k=2,可以找到a^(a+1)=1:如果k=3,首先只取两个就得到一个下界为1,但是可能出现为0的情况,下面再仔细讨论.如果k>=4,可以找到两组a^(a + 1) = 1,所以答案是0. 现在剩下的问题就是如何判断k=3的情况答案能否为0了.答案为0时我们只有可能取了3个数,设它们为…
Description Little Victor adores the sets theory. Let us remind you that a set is a group of numbers where all numbers are pairwise distinct. Today Victor wants to find a set of integers S that has the following properties: for all x the following in…
Little Victor and Set 其他都很好求, 只有k == 3的时候很难受.. 我们找到第一个不大于l的 t, 答案为 l, 3 * t, (3 * t) ^ l 感觉好像是对的, 感觉又不会证明, 啊, 我好菜啊. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #…
题目链接:http://codeforces.com/contest/984 A. Game time limit per test:2 seconds memory limit per test:512 megabytes input:standard input output:standard output Two players play a game. Initially there are nn integers a1,a2,…,ana1,a2,…,an written on the…
D. Little Victor and Set time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Little Victor adores the sets theory. Let us remind you that a set is a group of numbers where all numbers are pairw…
题目链接: http://codeforces.com/problemset/problem/919/E 题意: 让你求满足 \(na^n\equiv b \pmod p\) 的 \(n\) 的个数. \(2 ≤ p ≤ 10^{6} + 3, 1 ≤ a, b < p, 1 ≤ x ≤ 10^{12}\). 题解: 因为: $n \mod p $的循环节是 \(p\) \(a^{n} \mod p\)的循环节是 \(p-1\).(费马小定理) 所以: \(na^n \mod p​\)的循环节为…
题意:从区间[L,R]中选取不多于k个数,使这些数异或和尽量小,输出最小异或和以及选取的那些数. 解法:分类讨论. 设选取k个数. 1. k=4的时候如果区间长度>=4且L是偶数,那么可以构造四个数(L,L+1,L+2,L+3),这样的话(L^(L+1)) ^ ((L+2)^(L+3)) = 0,最优 如果L不是偶数,那么看从L+1到R有没有四个数,如果有则取该四个数,否则最小异或和达不到0,也达不到1了,不再考虑k=4,k=3时还有可能等于0,所以转到k=3 2. k=3时,要使异或和为0,那…
最近的CF几乎都没打,感觉挺水的一个题,不过自己仿佛状态不在,看题解才知道做法. 输入l, r, k (1 ≤ l ≤ r ≤ 1012; 1 ≤ k ≤ min(106, r - l + 1)). 从[l,r]选至多k个数使得选出的数的异或值最小,输出最小异或值和方案. 分类讨论,首先如果r-l+1<=4,枚举集合解决之. 先面讨论r-l+1>=5的情况: 此时有至少5个数可以选择,故至少有连续的4个数满足2x,2x+1,2x+2,2x+3. k==1时显然方案为{l}.k==2时,显然方案…
Description Karen just got home from the supermarket, and is getting ready to go to sleep. After taking a shower and changing into her pajamas, she looked at her shelf and saw an album. Curious, she opened it and saw a trading card collection. She re…