codeforces 322 B Ciel and Flowers】的更多相关文章

题目链接 有红绿蓝三种颜色的画,每种拿三朵可以组成一束花,或者各拿一朵组成花束,告诉你每种花的数目,求出可能组成最多的花束. 如果你的代码过不了,考虑一下 8 8 9这种组合.  因为数据量很大,我的思想就是局部和总体采用不同的策略. #include <iostream> #include <algorithm> using namespace std; int main() { int r, g, b; while (cin >> r >> g >…
题目链接 题意: 有n个男孩和m个女孩,他们要结对跳舞,每对要有一个女孩和一个男孩,而且其中一个要求之前没有和其他人结对,求出最大可以结多少对. 如图,一条线代表一对,只有这样三种情况. #include <iostream> #include <algorithm> #include <stdio.h> using namespace std; int main() { int n, m; while (cin >> n >> m) { int…
B. Ciel and Flowers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Fox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make seve…
链接:http://codeforces.com/contest/322/problem/B 这题做错了.没考虑周全. #include <cstdio> #include <cstdlib> #include <iostream> #include <algorithm> using namespace std; int main(void) { int r, g, b; while (~scanf("%d%d%d", &r,…
题目链接:http://codeforces.com/problemset/problem/322/B 题目意思:给定红花.绿花和蓝花的朵数,问组成四种花束(3朵红花,3朵绿花,3朵蓝花,1朵红花+1朵绿花+1朵蓝花)的总数最大为多少. 一开始以为是水题,其实很多情况都没有考虑到,反反复复修改终于过了. 其实要考虑两种情况,这两种情况较好的那种就是最优解.姑且把四种花束分为两种类型:清一色型(3朵红,3朵绿,3朵蓝)和混杂型(红绿蓝各一朵). 第一种情况就是,保证清一色型最多(3种花都要除以3)…
题目链接:http://codeforces.com/problemset/problem/459/B 题目意思:有 n 朵 flowers,每朵flower有相应的 beauty,求出最大的beauty 差 和 要达到这个最大的差 的取法有多少种. 一下子wa,是因为没考虑到整个序列都是相同的beauty 时的情况,以为取法是一种= =.注意,beauty 差为0都是合法的.还有注意这句话:Two ways are considered different if and only if the…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The…
Fox Ciel is playing a card game with her friend Jiro. Jiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known that position of all Ciel's cards…
Discription 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 (hence they are indistinguishable). Also, no two boxes have flowers of the…
[题目链接] http://codeforces.com/contest/451/problem/E [算法] 容斥原理 [代码] #include<bits/stdc++.h> using namespace std; typedef long long ll; ; int i,j,n,s,ans,MASK; ll m,t; ll a[],f[]; ]; inline int power(int a,int n) { ,b = a; while (n) { ) res = 1ll * res…
方法可以转化一下,先计算每一个鲨鱼在自己范围内的数能被所给素数整除的个数有几个,从而得到能被整除的概率,设为f1,不能被整除的概率设为f2. 然后计算每相邻两只鲨鱼能获得钱的期望概率,f=w[id1].f1*w[id2].f2+w[id1].f2*w[id2].f1+w[id1].f1*w[id2].f1; f*2000就是这两只鲨鱼能获得的期望金钱,然后枚举一下所有相邻的鲨鱼,累加即可. #include<cstdio> #include<cstring> #include<…
题意:N个人排成一行,分成K组,要求每组的不和谐值之和最小. 思路:开始以为是斜率优化DP,但是每个区间的值其实已经知道了,即是没有和下标有关的未知数了,所以没必要用斜率. 四边形优化. dp[i][j]表示前j个人分为i组的最小代价. 622ms #include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;i++) using namespace std; ; ][maxn],pos[][maxn]; void read(in…
[题目链接]:click here~~ [题目大意]:一个robot 机器人 .能够依据给定的指令行动,给你四种指令,robot初始位置是(0,0).指令一出.robot会反复行动,推断是否能在无限行动的情况下经过点(n,m). [解题思路]事实上细致模拟一下,能够发现是有周期的.推断就可以,见代码吧~~ 代码: #include <iostream> #include <algorithm> #include <bits/stdc++.h> using namespa…
传送门 解题思路: 假如只有 s 束花束并且不考虑 f ,那么根据隔板法的可重复的情况时,这里的答案就是 假如说只有一个 f 受到限制,其不合法时一定是取了超过 f 的花束 那么根据组合数,我们仍然可以算出其不合法的解共有: 最后,由于根据容斥,减两遍的东西要加回来,那么含有偶数个 f 的项为正,奇数个时为负. 答案就是: 搜索答案,使用Lucas定理,计算组合数上下约去. 代码: #include<cstdio> #include<cstring> #include<alg…
题目链接 给你一串只有0和1的数字,然后对某一区间的数翻转1次(0变1 1变0),只翻转一次而且不能不翻转,然后让你计算最多可能出现多少个1. 这里要注意很多细节 比如全为1,要求必须翻转,这时候我们只要翻转一个1就可以了,对于其他情况,我们只要计算区间里面如果0多于1,将其翻转后计算1的总数,然后取最大值. //cf 191 A //2013-07-04-22.13 #include <stdio.h> #include <string.h> #include <algor…
B. Ciel and Flowers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Fox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make seve…
A. Ciel and Dancing 模拟. B. Ciel and Flowers 混合类型的数量只能为0.1.2,否则3个可以分成各种类型各自合成. C. Ciel and Robot 考虑一组命令得到的点集,那么后面的点的起始点会对应于其中点集中的一个点. D. Ciel and Duel 两种策略: atk-atk:一个取最小的前若干个,一个取最大的若干个. atk-def.atk:对于def状态的,需要优先取最靠近的值抵消,剩余atk状态的也是取最近的. E. Ciel the Co…
Fox And Jumping CodeForces - 510D Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0. There are also n cards, each card…
Fox And Two Dots CodeForces - 510B Fox Ciel 正在玩一个手机拼图游戏,被称之为 "Two Dots".基础关卡是在一个大小为 n × m的棋盘上游戏,类似于这样: 每个单元格包含了一个具有某种颜色的点.我们将使用不同的大写拉丁字符,表示不同的颜色. 这个游戏的关键是,找到同色环.例如,考虑图上的 4 个蓝色点,它们形成了一个环.正式地,我们将一个点序列 d1, d2, ..., dk 称作一个环 ,当且仅当它满足以下的条件: 这 k 个点不同:…
E. Ciel the Commander Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/322/problem/E Description Now Fox Ciel becomes a commander of Tree Land. Tree Land, like its name said, has n cities connected by n - 1 undirected ro…
C. Watering Flowers 题目连接: http://www.codeforces.com/contest/617/problem/C Descriptionww.co A flowerbed has many flowers and two fountains. You can adjust the water pressure and set any values r1(r1 ≥ 0) and r2(r2 ≥ 0), giving the distances at which t…
题目链接:Codeforces 451E Devu and Flowers 题目大意:有n个花坛.要选s支花,每一个花坛有f[i]支花.同一个花坛的花颜色同样,不同花坛的花颜色不同,问说能够有多少种组合. 解题思路:2n的状态,枚举说那些花坛的花取超过了,剩下的用C(n−1sum+n−1)隔板法计算个数.注意奇数的位置要用减的.偶数的位置用加的.容斥原理. #include <cstdio> #include <cstring> #include <cmath> #in…
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…
[Codeforces 321D][2018HN省队集训D4T2] Ciel and Flipboard 题意 给定一个 \(n\times n\) 的矩阵 \(A\), (\(n\) 为奇数) , 每次可以选 \(A\) 的一个 \(\frac {n+1}2 \times \frac {n+1} 2\) 的子矩阵并让这个子矩阵中的所有值取反. 进行若干次操作最大化整个矩阵中的元素值之和. 输出这个最大值. \(n\le 33\), \(|A_{i,j}|\le 1000\) 题解 毒瘤wls活…
话说好久没写算法代码了,工作了有点忙的了.只是算法始终是我的挚爱,故此还是尽量抽时间和挚爱来个约会. Codeforces的题目是最适合练手的了,以下是一道不算难的动态规划法题目.先上题: D. Flowers time limit per test1.5 seconds memory limit per test256 megabytes inputstandard input outputstandard output We saw the little game Marmot made f…
题目链接:http://codeforces.com/problemset/problem/459/B 题意: 给出n支花,每支花都有一个漂亮值.挑选最大和最小漂亮值得两支花,问他们的差值为多少,并且有多少种选法(无先后顺序). 现场做时,想到的是:用multimap记录每个漂亮值出现的次数,并不断更新最大最小值. 这个方法很笨,而且multimap的val值是多余的. 需要注意特殊情况:max==min 代码如下: #include<iostream>//A - Pashmak and Fl…
Ciel the Commander Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 321C64-bit integer IO format: %I64d      Java class name: (Any) Now Fox Ciel becomes a commander of Tree Land. Tree Land, like its na…
D. Flowers time limit per test:1.5 seconds memory limit per test:256 megabytes We saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At every dinner he eats some red and white flo…
题目描述: Ciel the Commander time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Now Fox Ciel becomes a commander of Tree Land. Tree Land, like its name said, has n cities connected by n - 1 undire…
B. Alyona and flowers Problem Description: Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several of the subarrays suggested by her mother. After that, each of the flowe…