传送门 D. R2D2 and Droid Army time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An army of n droids is lined up in one row. Each droid is described by m integers a1, a2, ..., am, where ai is th…
题目链接:http://codeforces.com/contest/474/problem/F 题意简而言之就是问你区间l到r之间有多少个数能整除区间内除了这个数的其他的数,然后区间长度减去数的个数就是答案. 要是符合条件的话,那这个数的大小一定是等于gcd(a[l]...a[r]). 我们求区间gcd的话,既可以利用线段树性质区间递归下去然后返回求解,但是每次查询是log的,所以还可以用RMQ,查询就变成O(1)了. 然后求解区间内有多少个数的大小等于gcd的话,也是利用线段树的性质,区间递…
C. Day at the Beach Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/599/problem/C Description One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunately, the weather was bad, so the friends were unab…
D. The Child and Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/438/problem/D Description At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important…
题目地址:http://codeforces.com/contest/474/problem/F 由题意可知,最后能够留下来的一定是区间最小gcd. 那就转化成了该区间内与区间最小gcd数相等的个数.区间最小gcd一定小于等于区间最小值.所以仅仅要先推断最小值是否是最小gcd.若是的话,就求出最小值的个数.然后用r-l+1-个数就可以. 对于以上信息.能够用线段树来维护.分别维护区间gcd,区间最小值以及区间最小值的个数. 代码例如以下: #include <iostream> #includ…
D. Babaei and Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/D Description As you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake. Simple cake is a cylinder of som…
题目链接:http://codeforces.com/problemset/problem/438/D 给你n个数,m个操作,1操作是查询l到r之间的和,2操作是将l到r之间大于等于x的数xor于x,3操作是将下标为k的数变为x. 注意成段更新的时候,遇到一个区间的最大值还小于x的话就停止更新. #include <iostream> #include <cstdio> #include <cstring> using namespace std; typedef __…
B. "Or" Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/578/problem/B Description You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of the number…
题:https://codeforces.com/contest/1099/problem/F 题意:给定一个树,每个节点有俩个信息x和t,分别表示这个节点上的饼干个数和先手吃掉这个节点上一个饼干的的时间.然后有先手和后手俩个人. ◉先手可以这么操作:在规定总时间T到达某个节点然后一定要返回根节点1,期间可以选择吃掉某些节点上的某些饼干(前提是保证剩下的时间能够回到根节点): ◉后手可以这么操作:在先手到达的位置和这个位置的孩子之间的连边选择一条让先手吃得更多的边摧毁掉,也可以跳过这个过程: 问…
题意:做蛋糕,给出N个半径,和高的圆柱,要求后面的体积比前面大的可以堆在前一个的上面,求最大的体积和. 思路:首先离散化蛋糕体积,以蛋糕数量建树建树,每个节点维护最大值,也就是假如节点i放在最上层情况下的体积最大值dp[i].每次查询比蛋糕i小且最大体积的蛋糕,然后更新线段树.注意此题查询的技巧!!查询区间不变l,r,才能保证每次查到的是小且最大体积. #include<iostream> #include<string> #include<algorithm> #in…