【CodeforcesRound#277.5(Div.2)(C题)_html/css_WEB-ITnose】教程文章相关的互联网学习教程文章

CodeforcesRound#271(Div.2)F题Antcolony(线段树)_html/css_WEB-ITnose

题目地址:http://codeforces.com/contest/474/problem/F 由题意可知,最后可以留下来的一定是区间最小gcd。那就转化成了该区间内与区间最小gcd数相等的个数。区间最小gcd一定小于等于区间最小值,所以只要求最小值的个数。然后用r-l+1-个数即可。 对于以上信息,可以用线段树来维护。分别维护区间gcd,区间最小值以及区间最小值的个数。 代码如下: #include #include #include #include #include #include #include #inclu...

CodeforcesRound#271(Div.2)E题Pillars(线段树维护DP)_html/css_WEB-ITnose

题目地址:http://codeforces.com/contest/474/problem/E 第一次遇到这种用线段树来维护DP的题目。ASC中也遇到过,当时也很自然的想到了线段树维护DP,但是那题有简单方法,于是就没写。这次终于写出来了。。 这题的DP思想跟求最长上升子序列的思想是一样的。只不过这里的找前面最大值时会超时,所以可以用线段树来维护这个最大值,然后由于还要输出路径,所以要用线段树再来维护一个每个数在序列中所在的位置信息。 手残了好多...

CodeforcesRound#271(Div.2)_html/css_WEB-ITnose

A题:因为数据量太小,所以直接暴力替换就好。。。。 #include #include #include #include #include #include using namespace std;typedef long long ll;int arr[100010];int cnt[100010];int col[100010];int n,a,b;char c;string s = "qwertyuiopasdfghjkl;zxcvbnm,./";int main(){ while(cin>>c) { string input; cin>>input; if(c==L) { string output=""; for(...

CodeforcesRound#271(Div.2)解题报告_html/css_WEB-ITnose

题目地址:http://codeforces.com/contest/474 A题:Keyboard 模拟水题。 代码如下: #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define LL __int64char s[]={"qwertyuiopasdfghjkl;zxcvbnm,./"};int main(){ int i, x, j, len; char c, s1[200]; scanf("%c",&c); if(c==L) x=1; else x=-1; scanf("%s...

CodeforcesRound#271(Div.2)D.Flowers(递推预处理)_html/css_WEB-ITnose

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 flowers. Therefore a dinner can be represented as a sequence of several flowers, some of them white and some of them red. But, for a dinner to be tasty, there is a rule: Marmot wants to eat white flowers only in groups of sizek. ...

CodeforcesRound#272(Div.1)C(字符串DP)_html/css_WEB-ITnose

C. Dreamoon and Strings time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Dreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s as a result. Then he calculates that is defined ...

CodeforcesRound#272(Div.2)AK报告_html/css_WEB-ITnose

A. Dreamoon and Stairs time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Dreamoon wants to climb up a stair of n steps. He can climb 1 or 2 steps at each move. Dreamoon wants the number of...

CodeforcesRound#272(Div.2)_html/css_WEB-ITnose

链接 : http://codeforces.com/contest/476 D题yy,ABC水 A. Dreamoon and Stairs time limit per test 1 second memory limit per test 256 megabytes Dreamoon wants to climb up a stair of n steps. He can climb 1 or 2 steps at each move. Dreamoon wants the number of moves to be a mul...

CodeforcesRound#272(Div.1)D(字符串DP)_html/css_WEB-ITnose

D. Dreamoon and Binary time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Dreamoon saw a large integer x written on the ground and wants to print its binary form out. Dreamoon has accomplished the part of turning x into its binary form...

CodeforcesRound#274(Div.2)AExpression_html/css_WEB-ITnose

题目链接:Expression Expression time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integer...

CodeforcesRound#273(Div.2)_html/css_WEB-ITnose

Codeforces Round #273 (Div. 2) 题目链接 A:签到,只要判断总和是不是5的倍数即可,注意判断0的情况 B:最大值的情况是每个集合先放1个,剩下都丢到一个集合去,最小值是尽量平均去分 C:假如3种球从小到大是a, b, c,那么如果(a + b) 2 <= c这个比较明显答案就是a + b了,因为c肯定要剩余了,如果(a + b)2 > c的话,就肯定能构造出最优的(a + b + c) / 3,因为肯定可以先拿a和b去消除c,并且控制a和b成2倍关系或者消...

CodeforcesRound#274(Div.2)CExams_html/css_WEB-ITnose

题目链接:Exams Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be...

CodeforcesRound#273(Div.2)CTableDecorations_html/css_WEB-ITnose

题目链接:Table Decorations Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have r red, g green and b blue balloons. To decorate a single table for the banquet you need exactly three balloons. Three balloons attached to so...

CodeforcesRound#274(Div.2)E题:RidinginaLift(DP)_html/css_WEB-ITnose

题目地址:http://codeforces.com/contest/479/problem/E 这题的动态转移方程很好想,但是最显然的是k*n*n的复杂度,明显不可以。于是就想到了用线段树来维护DP信息,但是仅仅k*n就已经濒临TLE了。。在加上个log就会TLE了,于是也不行。上网搜了一下才发现用个前缀和的小技巧就可以。= =!用了好多次了居然没有想到。。。。智商捉急。。于是剩下的就很简单了。 本来还想着,不可能走到b的另一侧,于是就只算一侧就可以了。。但是...

CodeforcesRound#274(Div.2)_html/css_WEB-ITnose

链接:http://codeforces.com/contest/479 A. Expression time limit per test 1 second memory limit per test 256 megabytes Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of operations + and *...