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…
题目链接:Codeforces 439C Devu and Partitioning of the Array 题目大意:给出n个数,要分成k份,每份有若干个数,可是仅仅须要关注该份的和为奇数还是偶数,要求偶数堆的个数为p. 输出方案. 解题思路:首先先将数组依照奇偶排序.也能够分开储存. 然后先单独分k-p个奇数,然后后面的就将两个奇数当一个偶数分配.分配过程中计算是否满足,比方说奇数是否成对,以及是否分成了k堆. #include <cstdio> #include <cstring…
D. Devu and his Brother time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are giv…
 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…
题目 //参考了网上的代码 注意答案可能超过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…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 一开始所有的数字单独成一个集合. 然后用v[0]和v[1]记录集合的和为偶数和奇数的集合它们的根节点(并查集 然后先让v[0]的大小变成p //奇数+偶数是奇数 //奇数+奇数是偶数 //偶数+偶数是偶数 如果v[0].size < p 那么随便让两个和为奇数的集合,让他们合并在一起,加入到偶数集合中,那么v[0].size++,v[1].size-=2了 如果v[0].size > p 那么有两种方法  1.让两个偶数集合合…
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问题的思路: // // 第一个假设a字符串和b字符串相等,说直接YES // 假设b串全是0,直接YES // 注意到a串有一个性质,1的个数不会超过本身的加1. // a有个1的上限设为x,b有个1的个数设为y,则假设x < y // 那么直接NO. // // 如今普通情况下.就是模拟啦,找到a…
Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Description Input Output Print exactly one integer — the beauty of the product of the strings. Sample Input 3aba Sample Output 3 题解:这个题的思维难度其实不大,需要维护什么东西很容易想到,或…
Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Input The first line contains a single integer nn (2≤n≤150000) — the number of kittens. Each of the following n−1lines contains integers xi and yi (1≤xi,…
Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input Output The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwis…
Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input The first and only line contains a single integer mm (1≤m≤100000,1≤m≤100000). Output Print a single integer — the expected length of the array aa writte…
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原点开始走,方向自选(<- or ->),在过程中,若遇到一个权值>0的点,则将此权值计入答案,并归零.当次.此方向上的所有点均为0后,输出此时的答案. 然后,进行分析: 我们很容易想到这是一个贪心,我们将正的和负的分别存入两个数组,最初的方向为: \(zhengsum > fusum…
比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现rating掉了非常多,那个心痛啊! 只是.后来认真的读了题目,发现这次的div2并非非常难! 官方题解:http://codeforces.com/blog/entry/13568 A. Appleman and Easy Task 解析:         一个水题,推断每一个细胞周围是否都是有偶数…
题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits/stdc++.h> using namespace std; const int INF=0x3f3f3f3f; int dp[105][3]; int main() { int n; scanf("%d",&n); memset(dp,INF,sizeof(dp)); d…
题目链接:http://codeforces.com/contest/706/problem/C #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+3; const ll INF=1e18; ll dp[N][2]; string a[N],b[N]; int c[N]; int main() { int n; scanf("%d",&n); for(…
题目:http://codeforces.com/contest/401/problem/C 题意:n个0,m个1,求没有00或111的情况. 这么简单的题..... 做题的时候脑残了...,今天,贴一下ac的代码,警示一下自己 #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> using namespa…
A:A. Points and Segments (easy) 题目看了n久,開始认为尼玛这是div2的题目么,题目还标明了easy.. 意思是给你一n个点,m个区间,在n个点上放蓝球或者红球,然后让你找一种选择方案使得m个区间内的蓝球和红球数量之差不超过1. 開始想过用dfs,只是这仅仅是div2的A题而已.. 然后想了下,直接输出010101序列不就能够么. 交了一发,发现要先排个序,再输出就能够了. AC代码: #include<iostream> #include<cstdio&…
职务地址:http://codeforces.com/contest/460/problem/C 这个题是用二分枚举最小值.然后推断是否能在规定的次数内使得全部的数都达到这个值.推断的时候要用贪心的方法推断,从左往右遍历.这时候须要让每次浇花的范围尽量向右.所以当到达一个不得不浇花的地方时,要继续占用所须要的浇花次数.当浇花次数不够用的时候,就说明无法达到. 在我的代码中,c数组是记录当前到了该点的时候浇花范围的最右界.表示到了这个地方的时候少了多少次覆盖.y就代表当前这个数被多少个浇花范围覆盖…
http://codeforces.com/contest/711 C. Coloring Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where…
这是一场非常需要总结的比赛,交了3题,最后终测的时候3题全部没过,一下掉到了绿名,2333 Problem A 题意:给定区间[l1,r1],[l2,r2],然后给定一个整数k,求区间当中相交的元素,k这个点不可算 分析:画图即可得出答案,注意两个l1和r2,以及r1和l2刚好重合的情况,赛场上就是漏电这种情况 // // main.cpp // Codeforces // // Created by wanghan on 16/9/14. // Copyright © 2016年 wangha…
A题: 链接:http://codeforces.com/contest/580/problem/A dp,最长连续不上升子序列 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm> using namespace std; ; int a[maxn],dp[maxn]; in…
这场并没有做,做的赛后的,太晚了时间,中午做了两题,稍微贴一下,剩余的题目本周争取补完 A题: 链接:http://codeforces.com/contest/554/problem/A #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<vector> #include<stack>…
先送上一篇题解(虽然全英文的):http://codeforces.com/blog/entry/18034 A题:http://codeforces.com/problemset/problem/546/A 没什么好说的,SB题 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm&…
#451 Div2 F 题意 给出一个由数字组成的字符串,要求添加一个加号和等号,满足数字无前导 0 且等式成立. 分析 对于这种只有数字的字符串,可以快速计算某一区间的字符串变成数字后并取模的值,首先从右到左,将字符串转化为数字并取模,那么 \(h[i]\) 表示字符串 \(S[i...len]\) 转化成数字后并取模的值,如果要求区间 \([i, j]\) 所表示的数字是多少,首先求出 \(h[i] - h[j + 1]\),后面的 0 可以除掉,求一下逆元即可. 然后枚举一下,比一下就行了…
#452 Div2 F 题意 给出一个字符串, m 次操作,每次删除区间 \([l,r]\) 之间的字符 \(c\) ,输出最后得到的字符串. 分析 通过树状数组和二分,我们可以把给定的区间对应到在起始字符串上的区间. 然后暴力去删字符即可(因为最多只会删掉等同于字符串长度的字符个数),总共只有 62 种字符,set 维护下位置. code #include<bits/stdc++.h> using namespace std; typedef long long ll; const int…