CF701A Cards 题解】的更多相关文章

Content 有一个长度为 \(n\) 的数组 \(a_1,a_2,a_3,...,a_n\),试在其中找到 \(\dfrac{n}{2}\) 对数,使得每个数对的元素的和都相等. 数据范围:\(2\leqslant n\leqslant 100,1\leqslant a_i\leqslant 100\).\(n\) 保证是偶数. Solution 我们先算出这些数的总和 \(s\),然后每个数对的和就是 \(\dfrac{s}{\dfrac{n}{2}}=\dfrac{2s}{n}\),又由…
There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distri…
题面 首先发现:一个数最多会出现1次: 然后深入推出:一个数不会既用它又用它的相反数: 这样就可以依次考虑每一位了: 如果所有的数都不含有这一位,那么就直接把所有的数除以2 如果含有,那么就减去这一位的数,再除以2: 2 当含有的时候搜索就可以了: 注意需通过去重来优化dfs,否则会TLE掉: #include <bits/stdc++.h> #define N 100010 using namespace std; int a[N],b[21][N],ans[N],st[N],top=0;…
Content 有 \(n\) 张卡牌,每张卡牌上只会有大小写字母和 \(0\sim 9\) 的阿拉伯数字.有这样一个描述:"如果卡牌正面写有元音字母(\(\texttt{A,E,I,O,U}\) 五个字母中的一个),那么它的反面必然是偶数".你很想知道这个描述是否正确,因此你可以选择翻开一些卡牌来验证这个描述.求最坏情况下至少需要翻开的牌的数量. 数据范围:\(1\leqslant n\leqslant 50\). Solution 我们只需要找到元音字母和奇数的牌翻开就行.为什么是…
题目链接 luogu P1446 [HNOI2008]Cards 题解 题意就是求染色方案->等价类 洗牌方式构成成了一个置换群 然而,染色数限制不能用polay定理直接求解 考虑burnside引理 对于一个置换群其等价类的个数为置换中不动点的平均数 先暴力求出置换中的轮换,然后01背包DP求出不动点方案数 代码 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm…
Description Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the n…
Hongcow Buys a Deck of Cards 啊啊啊, 为什么我连这种垃圾dp都写不出来.. 不是应该10分钟就该秒掉的题吗.. 从dp想到暴力然后gg, 没有想到把省下的红色开成一维. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair&…
看到这道题,网上没有中文版的官方题解,于是就自己翻译了一遍. 不是机器翻译,是一个字一个字纯手翻译的,如果有错误欢迎指正. 比如我们有一张卡片,三个参数分别是 a1 = 4, b1 = 2, c1 = 3. 方便起见,我们令 p = q = r = 5. 考虑什么样的卡片能够击败这张. 我们可以固定一个参数c,来观察对于不同的c,有什么特殊的性质:   注意在第c个坐标系中,坐标为(a,b)的绿色方格代表一张卡片 (a, b, c) 可以击败我们这张卡片 (4, 2, 3). 因此,对于所有c个…
思路 是一道水题,可以用队列+模拟来写,注意不要拿完队列中的元素! 代码 #include<iostream> #include<cstdio> #include<queue> using namespace std; +; int main() { int n; cin>>n; queue<int>a;//队列 queue<int>b; int x,y; cin>>x; ;i<x;i++) { int x; cin…
Content 有 \(2n\) 个数,让你找出两两相等的 \(n\) 对数的编号,或者方案不存在. 数据范围:\(1\leqslant n\leqslant 3\times 10^5,1\leqslant a_i\leqslant 5000\). Solution 这题目还是挺好做的. 首先边读入边记录,如果一个数出现在前或者从未出现过,记录下来,并找后面有没有相等的数,有的话记录答案并将所有的记录清除(就相当于你找到了相等的一对数,在开始继续找时就会被认为没有出现过),如果不是恰好 \(n\…