758B Blown Garland】的更多相关文章

B. Blown Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.…
题目链接:http://codeforces.com/contest/758/problem/B 题意:一个原先为4色环的链子少了部分,要你找出死的最少的一种可能,各输出四种颜色的死了多少. 分析:就是要找出这个链子是那个部分.那么就有4!种可能. #include <bits/stdc++.h> using namespace std; ][] = { "BGRY", "BGYR", "BRGY", "BRYG"…
B. Blown Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland. Now he has a goal to…
http://codeforces.com/problemset/problem/758/B 题意:给出一个字符串,每4个位置对应一个颜色,如果为‘!’的话,代表该灯泡是坏的,问最后每个颜色坏的灯泡的数目. 思路:题意实在挺难懂的(可能我到现在还没看懂).看样例看了好久才看出来.例如最后一个样例“!GB!RG!Y!”:可以拆分成"!GB!”,"RG!Y","!",R只在第一个位置出现,说明R是在第一个位置的,以此类推,G是在第二个位置,B是在第三个位置,Y…
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland. Now he has a go…
题意:输入是由连续的RYGB和字符!组成的字符串,R代表红灯,Y代表黄灯,G代表绿灯,B代表蓝灯.简而言之,就是给定的字符串保证了下标对4取余相同的灯颜色都相同,但是有的地方为‘!’代表这个灯坏了,然后分别输出坏了的红.蓝.黄.绿灯的数量. 分析:因为下标对4取余相同的灯颜色都相同,所以确定了前四个灯的颜色,后面的灯都是前四个灯颜色的不断循环,两个map映射一下就可以了. #include<bits/stdc++.h> #define Min(a, b) ((a < b) ? a : b…
B. Blown Garland time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.…
A. Holiday Of Equality time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citi…
POJ 1759 Garland  这个题wa了27次,忘了用一个数来储存f[n-1],每次由于二分都会改变f[n-1]的值,得到的有的值不精确,直接输出f[n-1]肯定有问题. 这个题用c++交可以过,g++交过不了, f[i]=2+2*f[i-1]-f[i-2]; f[0]=A,f[1]=x; 二分枚举x的值,最终得到B的值(不是f[n-1]), 上述递推式是非齐次的二阶递推式,解其齐次特征方程,可以得到f[n-1]的齐次时的表达式,对于非齐次的,目前我还没法求出通式, B与f[n-1]的关…
Description The New Year garland consists of N lamps attached to a common wire that hangs down on the ends to which outermost lamps are affixed. The wire sags under the weight of lamp millimeter lower than the average height of the two adjacent lamps…
Garland Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2365   Accepted: 1007 Description The New Year garland consists of N lamps attached to a common wire that hangs down on the ends to which outermost lamps are affixed. The wire sags…
C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R',…
D. Diverse Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
题目链接:http://codeforces.com/problemset/problem/1108/D time limit per test 1 secondmemory limit per test 256 megabytesinput standard inputoutput standard output You have a garland consisting of n lamps. Each lamp is colored red, green or blue. The colo…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
As Gerald, Alexander, Sergey and Gennady are already busy with the usual New Year chores, Edward hastily decorates the New Year Tree. And any decent New Year Tree must be decorated with a good garland. Edward has lamps of m colors and he wants to mak…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' - colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' - colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
C. Garland time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Once at New Year Dima had a dream in which he was presented a fairy garland. A garland is a set of lamps, some pairs of which are…
题目链接:http://poj.org/problem?id=1759 Garland Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2477   Accepted: 1054 Description The New Year garland consists of N lamps attached to a common wire that hangs down on the ends to which outermo…
A. New Year Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood,…
排列组合题 题意 用m种颜色的彩球装点n层的圣诞树.圣诞树的第i层恰由l[i]个彩球串成一行,且同一层内的相邻彩球颜色不同,同时相邻两层所使用彩球的颜色集合不同.求有多少种装点方案,答案对p取模. 只要任一位置上的彩球颜色不同,就算作不同的方案. 1 <= n,m <= 10^6, 2 <= p <= 10^9, 1 <= l[i] <= 5000, Σl[i] <= 10^7 若只考虑一层,就是bzoj1008的越狱,但是要考虑上下两层不同,卒. 考虑只在一层中…
Description 用$m$种颜色的彩球装点$n$层的圣诞树.圣诞树的第$i$层恰由$l[i]$个彩球串成一行,且同一层内的相邻彩球颜色不同,同时相邻两层所使用彩球的颜色集合不同. 求有多少种装点方案,答案对$p$取模. 只要任一位置上的彩球颜色不同,就算作不同的方案. Input 第一行三个整数$n,m,p$,表示圣诞树的层数.彩球的颜色数和取模的数. 接下来一行包含$n$个整数,表示$l[i]$. Output 一个整数表示答案. Sample Input 3 2 1000 3 1 2…
 挂彩灯 题目大意:就是要布场的时候需要挂彩灯,彩灯挂的高度满足: H1 = A Hi = (Hi-1 + Hi+1)/2 - 1, for all 1 < i < N HN = B Hi >= 0, for all 1 <= i <= N 现在已知彩灯的个数和第一个彩灯挂的高度,要你求最后一个彩灯最低能挂多高? 这又是个最大化最小值的问题,从题目中我们可以看到递推公式的影子,其实这一题我们只要把答案二分,然后根据递推公式写出通项公式,一个灯一个灯看是否有低于0的高度就好 递…
二分H2的位置,判断条件为是否有Hi < 0 #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> #include <cmath> using namespace std; ; int N; double A; int dcmp( double a ) { ; ? - : ; } bool cal( double mid, double &…
[题目链接] http://poj.org/problem?id=1759 [题目大意] 有n个数字H,H[i]=(H[i-1]+H[i+1])/2-1,已知H[1],求最大H[n], 使得所有的H均大于0. [题解] 我们得到递推式子H[i]=2*H[i-1]+2-H[i-2],发现H[n]和H[2]成正相关 所以我们只要二分H[2]的取值,同时计算每个H是否大于等于0即可. [代码] #include <cstdio> int n; double H[1010],A,B; bool che…
题意:灯有三种颜色R,G,B.只要同一种颜色相邻就不可以.问最少需要换几次,可以使在一串灯中没有相邻灯的颜色相同. 思路:贪心思路:我们知道一个程序都是要子阶段,然后子阶段各个组合起来形成这个程序.那么对于每一个子阶段的贪心,就能形成整个程序的贪心. 贪心思路就是:只要出现相邻的相同a[i]==a[i+1], 然后,就选择一个a[i+1]!=a[i]&&a[i+1]!=a[i+2]的情况.注意:最后2个字母相同时,需要自己处理一下. #include<iostream> usi…