题目链接:Codeforces 439C Devu and Partitioning of the Array 题目大意:给出n个数,要分成k份,每份有若干个数,可是仅仅须要关注该份的和为奇数还是偶数,要求偶数堆的个数为p. 输出方案. 解题思路:首先先将数组依照奇偶排序.也能够分开储存. 然后先单独分k-p个奇数,然后后面的就将两个奇数当一个偶数分配.分配过程中计算是否满足,比方说奇数是否成对,以及是否分成了k堆. #include <cstdio> #include <cstring…
题目 //参考了网上的代码 注意答案可能超过32位 //要达成目标,就是要所有数列a的都比数列b的要小或者等于 //然后,要使最小的要和最大的一样大,就要移动(大-小)步, //要使较小的要和较大的一样大,也是要移动(较大-较小)步 //然后都加在一起就好了 #include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> using namespace std; #def…
题目 //这是一道有n多情况的烦死人的让我错了n遍的模拟题 #include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> using namespace std; ],n,k,p; ]; ,ou=; int main() { memset(vis,,sizeof(vis)); cin >> n >> k >> p; ;i<n;i…
题意:给你n个数,然后分成k部分,每一个部分的和为偶数的有p个,奇数的有k-p个,如果可以划分,输出其中的一种,不可以输出NO; 思路:先输出k-p-1个奇数,再输出p-1个偶数,剩余的在进行构造.  奇数+奇数=偶数. #include <cstdio> #include <cstring> #include <vector> #include <iostream> #include <algorithm> #define maxn 10001…
C. Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Devu being a small kid, likes to play a lot, but he only likes to play with arrays. While playing he ca…
 Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Devu being a small kid, likes to play a lot, but he only likes to play with arrays. While playing he came…
题目链接: 传送门 Devu and Partitioning of the Array time limit per test:1 second     memory limit per test:256 megabytes Description Devu being a small kid, likes to play a lot, but he only likes to play with arrays. While playing he came up with an interes…
Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Devu being a small kid, likes to play a lot, but he only likes to play with arrays. While playing he came…
注意p的边界情况,p为0,或者 p为k 奇数+偶数 = 奇数 奇数+奇数 = 偶数 #include <iostream> #include <vector> #include <set> #include <algorithm> #include <cmath> using namespace std; int main(){ int n,k,p; long a; cin >> n >> k >> p; ve…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 一开始所有的数字单独成一个集合. 然后用v[0]和v[1]记录集合的和为偶数和奇数的集合它们的根节点(并查集 然后先让v[0]的大小变成p //奇数+偶数是奇数 //奇数+奇数是偶数 //偶数+偶数是偶数 如果v[0].size < p 那么随便让两个和为奇数的集合,让他们合并在一起,加入到偶数集合中,那么v[0].size++,v[1].size-=2了 如果v[0].size > p 那么有两种方法  1.让两个偶数集合合…